diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-08-03 04:05:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-02 22:05:34 -0400 |
commit | db287e216dd752bfcb3484cbfd93225e8463c363 (patch) | |
tree | 11c5cf2e8be82fae5674949747e1b7691252ee3b /cli/tools/test/mod.rs | |
parent | 480894e5c8f9532a4c42477cdf5c058cb8e9e1e3 (diff) |
refactor: use '--reporter' and '--junit-path' flags for 'deno test' (#20031)
This commit adds "--reporter" and "--junit-path" flags to "deno test"
subcommand instead of using "--dot" and "--junit" flags.
Diffstat (limited to 'cli/tools/test/mod.rs')
-rw-r--r-- | cli/tools/test/mod.rs | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/cli/tools/test/mod.rs b/cli/tools/test/mod.rs index c3fb6f772..101817ac9 100644 --- a/cli/tools/test/mod.rs +++ b/cli/tools/test/mod.rs @@ -361,6 +361,7 @@ struct TestSpecifiersOptions { log_level: Option<log::Level>, specifier: TestSpecifierOptions, reporter: TestReporterConfig, + junit_path: Option<String>, } #[derive(Debug, Clone)] @@ -394,28 +395,23 @@ impl TestSummary { fn get_test_reporter(options: &TestSpecifiersOptions) -> Box<dyn TestReporter> { let parallel = options.concurrent_jobs.get() > 1; - match &options.reporter { + let reporter: Box<dyn TestReporter> = match &options.reporter { TestReporterConfig::Dot => Box::new(DotTestReporter::new()), TestReporterConfig::Pretty => Box::new(PrettyTestReporter::new( parallel, options.log_level != Some(Level::Error), )), - TestReporterConfig::Junit(path) => { - let junit = Box::new(JunitTestReporter::new(path.clone())); - // If junit is writing to stdout, only enable the junit reporter - if path == "-" { - junit - } else { - Box::new(CompoundTestReporter::new(vec![ - Box::new(PrettyTestReporter::new( - parallel, - options.log_level != Some(Level::Error), - )), - junit, - ])) - } + TestReporterConfig::Junit => { + Box::new(JunitTestReporter::new("-".to_string())) } + }; + + if let Some(junit_path) = &options.junit_path { + let junit = Box::new(JunitTestReporter::new(junit_path.to_string())); + return Box::new(CompoundTestReporter::new(vec![reporter, junit])); } + + reporter } /// Test a single specifier as documentation containing test programs, an executable test module or @@ -1162,6 +1158,7 @@ pub async fn run_tests( fail_fast: test_options.fail_fast, log_level, reporter: test_options.reporter, + junit_path: test_options.junit_path, specifier: TestSpecifierOptions { filter: TestFilter::from_flag(&test_options.filter), shuffle: test_options.shuffle, @@ -1293,6 +1290,7 @@ pub async fn run_tests_with_watch( fail_fast: test_options.fail_fast, log_level, reporter: test_options.reporter, + junit_path: test_options.junit_path, specifier: TestSpecifierOptions { filter: TestFilter::from_flag(&test_options.filter), shuffle: test_options.shuffle, |