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:
parent
e0a269c23a
commit
2cbd1b40cb
4 changed files with 17 additions and 5 deletions
|
@ -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,
|
||||
|
|
5
cli/tests/testdata/test/filtered_out_only.out
vendored
Normal file
5
cli/tests/testdata/test/filtered_out_only.out
vendored
Normal 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])
|
||||
|
2
cli/tests/testdata/test/filtered_out_only.ts
vendored
Normal file
2
cli/tests/testdata/test/filtered_out_only.ts
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
Deno.test("foo", () => {});
|
||||
Deno.test("bar", { only: true }, () => {});
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue