From e0a269c23af2bccfa71d7a22506a348574be138a Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 6 Sep 2023 14:54:21 +0200 Subject: fix: don't show filtered test suites as running (#20385) --- cli/tools/test/mod.rs | 4 ++++ cli/tools/test/reporters/pretty.rs | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'cli/tools') diff --git a/cli/tools/test/mod.rs b/cli/tools/test/mod.rs index 296d306e2..7ab74ff7c 100644 --- a/cli/tools/test/mod.rs +++ b/cli/tools/test/mod.rs @@ -343,6 +343,7 @@ struct TestSpecifiersOptions { concurrent_jobs: NonZeroUsize, fail_fast: Option, log_level: Option, + filter: bool, specifier: TestSpecifierOptions, reporter: TestReporterConfig, junit_path: Option, @@ -384,6 +385,7 @@ fn get_test_reporter(options: &TestSpecifiersOptions) -> Box { TestReporterConfig::Pretty => Box::new(PrettyTestReporter::new( parallel, options.log_level != Some(Level::Error), + options.filter, )), TestReporterConfig::Junit => { Box::new(JunitTestReporter::new("-".to_string())) @@ -1144,6 +1146,7 @@ pub async fn run_tests( concurrent_jobs: test_options.concurrent_jobs, fail_fast: test_options.fail_fast, log_level, + filter: test_options.filter.is_some(), reporter: test_options.reporter, junit_path: test_options.junit_path, specifier: TestSpecifierOptions { @@ -1276,6 +1279,7 @@ pub async fn run_tests_with_watch( concurrent_jobs: test_options.concurrent_jobs, fail_fast: test_options.fail_fast, log_level, + filter: test_options.filter.is_some(), reporter: test_options.reporter, junit_path: test_options.junit_path, specifier: TestSpecifierOptions { diff --git a/cli/tools/test/reporters/pretty.rs b/cli/tools/test/reporters/pretty.rs index 394a7c490..8a2b77bb0 100644 --- a/cli/tools/test/reporters/pretty.rs +++ b/cli/tools/test/reporters/pretty.rs @@ -8,6 +8,7 @@ pub struct PrettyTestReporter { parallel: bool, echo_output: bool, in_new_line: bool, + filter: bool, scope_test_id: Option, cwd: Url, did_have_user_output: bool, @@ -18,11 +19,16 @@ pub struct PrettyTestReporter { } impl PrettyTestReporter { - pub fn new(parallel: bool, echo_output: bool) -> PrettyTestReporter { + pub fn new( + parallel: bool, + echo_output: bool, + filter: bool, + ) -> PrettyTestReporter { PrettyTestReporter { parallel, echo_output, in_new_line: true, + filter, scope_test_id: None, cwd: Url::from_directory_path(std::env::current_dir().unwrap()).unwrap(), did_have_user_output: false, @@ -133,7 +139,7 @@ impl TestReporter for PrettyTestReporter { fn report_plan(&mut self, plan: &TestPlan) { self.summary.total += plan.total; self.summary.filtered_out += plan.filtered_out; - if self.parallel { + if self.parallel || (self.filter && plan.total == 0) { return; } let inflection = if plan.total == 1 { "test" } else { "tests" }; -- cgit v1.2.3