summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Hagemeister <marvin@deno.com>2023-09-06 14:54:21 +0200
committerGitHub <noreply@github.com>2023-09-06 14:54:21 +0200
commite0a269c23af2bccfa71d7a22506a348574be138a (patch)
tree7d1f2fb11fb8c13eedb44ef1b2bbf420caea962b
parent147c845c95bfd55548d5b5b56d70f0a616410e0d (diff)
fix: don't show filtered test suites as running (#20385)
-rw-r--r--cli/tests/integration/test_tests.rs6
-rw-r--r--cli/tests/testdata/test/hide_empty_suites.out4
-rw-r--r--cli/tools/test/mod.rs4
-rw-r--r--cli/tools/test/reporters/pretty.rs10
4 files changed, 22 insertions, 2 deletions
diff --git a/cli/tests/integration/test_tests.rs b/cli/tests/integration/test_tests.rs
index 030da05e1..f84c2a560 100644
--- a/cli/tests/integration/test_tests.rs
+++ b/cli/tests/integration/test_tests.rs
@@ -278,6 +278,12 @@ itest!(clear_timeout {
output: "test/clear_timeout.out",
});
+itest!(hide_empty_suites {
+ args: "test --filter none test/pass.ts",
+ exit_code: 0,
+ output: "test/hide_empty_suites.out",
+});
+
itest!(finally_timeout {
args: "test test/finally_timeout.ts",
exit_code: 1,
diff --git a/cli/tests/testdata/test/hide_empty_suites.out b/cli/tests/testdata/test/hide_empty_suites.out
new file mode 100644
index 000000000..d270cb05a
--- /dev/null
+++ b/cli/tests/testdata/test/hide_empty_suites.out
@@ -0,0 +1,4 @@
+Check [WILDCARD]/test/pass.ts
+
+ok | 0 passed | 0 failed | 16 filtered out ([WILDCARD])
+
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<NonZeroUsize>,
log_level: Option<log::Level>,
+ filter: bool,
specifier: TestSpecifierOptions,
reporter: TestReporterConfig,
junit_path: Option<String>,
@@ -384,6 +385,7 @@ fn get_test_reporter(options: &TestSpecifiersOptions) -> Box<dyn TestReporter> {
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<usize>,
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" };