summaryrefslogtreecommitdiff
path: root/rust/src
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/tester.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/rust/src/tester.rs b/rust/src/tester.rs
index 019989b..eb66d4e 100644
--- a/rust/src/tester.rs
+++ b/rust/src/tester.rs
@@ -1,3 +1,4 @@
+use serde::{Deserialize, Serialize};
use std::{
fs::{self, read_to_string, File},
path::PathBuf,
@@ -13,9 +14,20 @@ pub fn main() {
let run = traverse(&args)
.and_then(|paths| run_test(&proc, &paths))
.expect("Failed to traverse directory");
- println!("{:?}", run)
+ println!("{}", serde_json::to_string_pretty(&run).unwrap());
} else {
- println!("Usage: tester <process> <directory>+");
+ println!(
+ r#"Usage: tester [options] <directory>+
+
+Options:
+ -p, --process The process to run. If the given process is not a
+ an absolute path, it will be resolved against the
+ PATH environment variable.
+ -j, --json Output the results in JSON format (default: false)
+ -h, --help Display this help message
+ -v, --version Display the version of the tester
+"#
+ );
}
}
@@ -34,13 +46,13 @@ fn traverse(args: &[String]) -> Result<Vec<PathBuf>, String> {
Ok(files)
}
-#[derive(Debug)]
+#[derive(Debug, Serialize, Deserialize)]
pub enum TestResult {
TestSucceeded,
TestFailed(String, String),
}
-#[derive(Debug)]
+#[derive(Debug, Serialize, Deserialize)]
pub struct TestRun {
file: String,
test_result: TestResult,