From e8258e0210c4690a1fbbcefe0e6a859da8efc19b Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Tue, 6 Jul 2021 09:20:33 +0800 Subject: feat(test): add --shuffle flag to randomize test ordering (#11163) --- cli/tests/integration/test_tests.rs | 12 ++++++++++++ cli/tests/test/shuffle.out | 39 +++++++++++++++++++++++++++++++++++++ cli/tests/test/shuffle/bar_test.ts | 3 +++ cli/tests/test/shuffle/baz_test.ts | 3 +++ cli/tests/test/shuffle/foo_test.ts | 3 +++ 5 files changed, 60 insertions(+) create mode 100644 cli/tests/test/shuffle.out create mode 100644 cli/tests/test/shuffle/bar_test.ts create mode 100644 cli/tests/test/shuffle/baz_test.ts create mode 100644 cli/tests/test/shuffle/foo_test.ts (limited to 'cli/tests') diff --git a/cli/tests/integration/test_tests.rs b/cli/tests/integration/test_tests.rs index 3bc81c5d3..c029b154d 100644 --- a/cli/tests/integration/test_tests.rs +++ b/cli/tests/integration/test_tests.rs @@ -114,3 +114,15 @@ itest!(unhandled_rejection { exit_code: 1, output: "test/unhandled_rejection.out", }); + +itest!(shuffle { + args: "test --shuffle test/shuffle", + exit_code: 0, + output_str: Some("[WILDCARD]"), +}); + +itest!(shuffle_with_seed { + args: "test --shuffle=42 test/shuffle", + exit_code: 0, + output: "test/shuffle.out", +}); diff --git a/cli/tests/test/shuffle.out b/cli/tests/test/shuffle.out new file mode 100644 index 000000000..04dd08ee2 --- /dev/null +++ b/cli/tests/test/shuffle.out @@ -0,0 +1,39 @@ +Check [WILDCARD]/test/shuffle/foo_test.ts +Check [WILDCARD]/test/shuffle/baz_test.ts +Check [WILDCARD]/test/shuffle/bar_test.ts +running 10 tests from [WILDCARD]/test/shuffle/foo_test.ts +test test 2 ... ok ([WILDCARD]) +test test 3 ... ok ([WILDCARD]) +test test 6 ... ok ([WILDCARD]) +test test 9 ... ok ([WILDCARD]) +test test 8 ... ok ([WILDCARD]) +test test 7 ... ok ([WILDCARD]) +test test 5 ... ok ([WILDCARD]) +test test 4 ... ok ([WILDCARD]) +test test 1 ... ok ([WILDCARD]) +test test 0 ... ok ([WILDCARD]) +running 10 tests from [WILDCARD]/test/shuffle/baz_test.ts +test test 2 ... ok ([WILDCARD]) +test test 3 ... ok ([WILDCARD]) +test test 6 ... ok ([WILDCARD]) +test test 9 ... ok ([WILDCARD]) +test test 8 ... ok ([WILDCARD]) +test test 7 ... ok ([WILDCARD]) +test test 5 ... ok ([WILDCARD]) +test test 4 ... ok ([WILDCARD]) +test test 1 ... ok ([WILDCARD]) +test test 0 ... ok ([WILDCARD]) +running 10 tests from [WILDCARD]/test/shuffle/bar_test.ts +test test 2 ... ok ([WILDCARD]) +test test 3 ... ok ([WILDCARD]) +test test 6 ... ok ([WILDCARD]) +test test 9 ... ok ([WILDCARD]) +test test 8 ... ok ([WILDCARD]) +test test 7 ... ok ([WILDCARD]) +test test 5 ... ok ([WILDCARD]) +test test 4 ... ok ([WILDCARD]) +test test 1 ... ok ([WILDCARD]) +test test 0 ... ok ([WILDCARD]) + +test result: ok. 30 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) + diff --git a/cli/tests/test/shuffle/bar_test.ts b/cli/tests/test/shuffle/bar_test.ts new file mode 100644 index 000000000..ca118dc0d --- /dev/null +++ b/cli/tests/test/shuffle/bar_test.ts @@ -0,0 +1,3 @@ +for (let i = 0; i < 10; i++) { + Deno.test(`test ${i}`, () => {}); +} diff --git a/cli/tests/test/shuffle/baz_test.ts b/cli/tests/test/shuffle/baz_test.ts new file mode 100644 index 000000000..ca118dc0d --- /dev/null +++ b/cli/tests/test/shuffle/baz_test.ts @@ -0,0 +1,3 @@ +for (let i = 0; i < 10; i++) { + Deno.test(`test ${i}`, () => {}); +} diff --git a/cli/tests/test/shuffle/foo_test.ts b/cli/tests/test/shuffle/foo_test.ts new file mode 100644 index 000000000..ca118dc0d --- /dev/null +++ b/cli/tests/test/shuffle/foo_test.ts @@ -0,0 +1,3 @@ +for (let i = 0; i < 10; i++) { + Deno.test(`test ${i}`, () => {}); +} -- cgit v1.2.3