🚖
TestDrive
What does it do?
TestDrive automatically scrapes input/output data from BOJ(Baekjoon Online Judge) and runs tests for your executable binary file!
How to use
- Clone this repo
- Build with Rust with
cargo build --release
test_drive
gets 2 arguments. First, the path to the binary, second the problem number. Following is the example runningtest_drive
for #1000 (A+B) at BOJ.
Example
/path-to-testdrive/target/release/test_drive ~/BOJ/bin/1000 1000
Output
Running tests on 1 cases...
[Case #1 Passed!]
Tip
If your editor that you use for problem solving supports any kind of user scripts, it is recommended to automate the process using it. Currently I am using VSCode as my main editor, and my user script for TestDrive is the following:
{
"tasks": [
{
"label": "compile and run for C++ (with BOJ support)",
"command": "g++-11",
"args": [
"${file}",
"-o",
"${fileDirname}/bin/${fileBasenameNoExtension}",
"-std=c++11",
"&&",
// Path to TestDrive
"~/Documents/test_drive/target/release/test_drive",
// Path to executable binary
"${fileDirname}/bin/${fileBasenameNoExtension}",
// Problem number (I save my source code name as the problem number)
"${fileBasenameNoExtension}"
],
"group": "build",
// Problem matcher
"problemMatcher": {
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
// The regular expression.
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
},
]
}
BTW I save my source code name as the problem number, so the process is simplified.
⚠️
Warning!
⚠️
This project contains lots of unhandled errors, bugs, etc. Also, it currently only supports macOS, since this program uses ~/Library/Caches/
as the directory to store caches.