@@ -114,6 +114,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
114114 )
115115 . optflag ( "" , "quiet" , "print one character per test instead of one line" )
116116 . optopt ( "" , "color" , "coloring: auto, always, never" , "WHEN" )
117+ . optflag ( "" , "json" , "emit json output instead of plaintext output" )
117118 . optopt ( "" , "logfile" , "file to log test execution to" , "FILE" )
118119 . optopt ( "" , "target" , "the target to build for" , "TARGET" )
119120 . optopt ( "" , "host" , "the host to build for" , "HOST" )
@@ -281,7 +282,12 @@ pub fn parse_config(args: Vec<String>) -> Config {
281282 && !opt_str2 ( matches. opt_str ( "adb-test-dir" ) ) . is_empty ( ) ,
282283 lldb_python_dir : matches. opt_str ( "lldb-python-dir" ) ,
283284 verbose : matches. opt_present ( "verbose" ) ,
284- quiet : matches. opt_present ( "quiet" ) ,
285+ format : match ( matches. opt_present ( "quiet" ) , matches. opt_present ( "json" ) ) {
286+ ( true , true ) => panic ! ( "--quiet and --json are incompatible" ) ,
287+ ( true , false ) => test:: OutputFormat :: Terse ,
288+ ( false , true ) => test:: OutputFormat :: Json ,
289+ ( false , false ) => test:: OutputFormat :: Pretty ,
290+ } ,
285291 only_modified : matches. opt_present ( "only-modified" ) ,
286292 color,
287293 remote_test_client : matches. opt_str ( "remote-test-client" ) . map ( PathBuf :: from) ,
@@ -339,7 +345,7 @@ pub fn log_config(config: &Config) {
339345 logv ( c, format ! ( "ar: {}" , config. ar) ) ;
340346 logv ( c, format ! ( "linker: {:?}" , config. linker) ) ;
341347 logv ( c, format ! ( "verbose: {}" , config. verbose) ) ;
342- logv ( c, format ! ( "quiet : {}" , config. quiet ) ) ;
348+ logv ( c, format ! ( "format : {:? }" , config. format ) ) ;
343349 logv ( c, "\n " . to_string ( ) ) ;
344350}
345351
@@ -501,7 +507,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
501507 filters : config. filters . clone ( ) ,
502508 filter_exact : config. filter_exact ,
503509 run_ignored : if config. run_ignored { test:: RunIgnored :: Yes } else { test:: RunIgnored :: No } ,
504- format : if config. quiet { test :: OutputFormat :: Terse } else { test :: OutputFormat :: Pretty } ,
510+ format : config. format ,
505511 logfile : config. logfile . clone ( ) ,
506512 run_tests : true ,
507513 bench_benchmarks : true ,
0 commit comments