Skip to content

Commit d7049ca

Browse files
committed
add the --json flag to compiletest
1 parent 64165aa commit d7049ca

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/tools/compiletest/src/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::str::FromStr;
99

1010
use crate::util::{add_dylib_path, PathBufExt};
1111
use lazycell::LazyCell;
12-
use test::ColorConfig;
12+
use test::{ColorConfig, OutputFormat};
1313

1414
#[derive(Clone, Copy, PartialEq, Debug)]
1515
pub enum Mode {
@@ -337,7 +337,7 @@ pub struct Config {
337337
pub verbose: bool,
338338

339339
/// Print one character per test instead of one line
340-
pub quiet: bool,
340+
pub format: OutputFormat,
341341

342342
/// Whether to use colors in test.
343343
pub color: ColorConfig,

src/tools/compiletest/src/main.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)