0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

fix(test): apply filter before checking for "only" (#20389)

This commit is contained in:
Nayeem Rahman 2023-09-06 17:07:37 +01:00 committed by GitHub
parent e0a269c23a
commit 2cbd1b40cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 5 deletions

View file

@ -91,6 +91,11 @@ itest!(test_with_malformed_config {
output: "test/collect_with_malformed_config.out",
});
itest!(test_filtered_out_only {
args: "test --quiet --filter foo test/filtered_out_only.ts",
output: "test/filtered_out_only.out",
});
itest!(parallel_flag {
args: "test test/short-pass.ts --parallel",
exit_code: 0,

View file

@ -0,0 +1,5 @@
running 1 test from ./test/filtered_out_only.ts
foo ... ok ([WILDCARD])
ok | 1 passed | 0 failed | 1 filtered out ([WILDCARD])

View file

@ -0,0 +1,2 @@
Deno.test("foo", () => {});
Deno.test("bar", { only: true }, () => {});

View file

@ -464,14 +464,14 @@ pub async fn test_specifier(
std::mem::take(&mut state.borrow_mut::<ops::testing::TestContainer>().0)
};
let unfiltered = tests.len();
let (only, no_only): (Vec<_>, Vec<_>) =
tests.into_iter().partition(|(d, _)| d.only);
let used_only = !only.is_empty();
let tests = if used_only { only } else { no_only };
let mut tests = tests
let tests = tests
.into_iter()
.filter(|(d, _)| options.filter.includes(&d.name))
.collect::<Vec<_>>();
let (only, no_only): (Vec<_>, Vec<_>) =
tests.into_iter().partition(|(d, _)| d.only);
let used_only = !only.is_empty();
let mut tests = if used_only { only } else { no_only };
if let Some(seed) = options.shuffle {
tests.shuffle(&mut SmallRng::seed_from_u64(seed));
}