diff options
| author | Arnaud Bailly <arnaud.bailly@iohk.io> | 2024-10-01 09:47:37 +0200 |
|---|---|---|
| committer | Arnaud Bailly <arnaud.bailly@iohk.io> | 2024-10-01 09:47:37 +0200 |
| commit | 19eb33ef04103ca4a6eb4af3e1940c2a5779e1ad (patch) | |
| tree | 9a81b550e269ff4cbfb61254d6bb2fbf11d8773b /rust/src/tester.rs | |
| parent | 055bd8d02ed6f9e97369fa1f77d918ea255dcb99 (diff) | |
| download | lambda-nantes-19eb33ef04103ca4a6eb4af3e1940c2a5779e1ad.tar.gz | |
Output tester's result in JSON
Diffstat (limited to 'rust/src/tester.rs')
| -rw-r--r-- | rust/src/tester.rs | 20 |
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, |
