From a0c0daac24c496e49e7c0abaae12f34723785a7d Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Tue, 29 Jun 2021 21:40:16 +0800 Subject: [PATCH] test(cli): harden test runner tests (#11166) --- cli/tests/067_test_no_run_type_error.out | 4 - cli/tests/integration/test_tests.rs | 96 +++++++------ cli/tests/test/deno_test.out | 26 ---- cli/tests/test/deno_test_fail_fast.out | 15 -- cli/tests/test/exit_sanitizer.out | 55 ++++++++ ...it_sanitizer_test.ts => exit_sanitizer.ts} | 0 cli/tests/test/exit_sanitizer_test.out | 28 ---- cli/tests/test/fail.out | 130 ++++++++++++++++++ cli/tests/test/fail.ts | 30 ++++ cli/tests/test/fail_fast.out | 22 +++ cli/tests/test/fail_fast.ts | 30 ++++ cli/tests/test/finally_timeout.out | 23 ++++ ...lly_cleartimeout.ts => finally_timeout.ts} | 0 cli/tests/test/ignore.out | 15 ++ cli/tests/test/ignore.ts | 9 ++ cli/tests/test/no_check.out | 8 ++ cli/tests/test/no_check.ts | 1 + .../{deno_test_no_color.ts => no_color.ts} | 0 cli/tests/test/no_run.out | 5 + cli/tests/test/no_run.ts | 1 + .../test/{deno_test_only.ts.out => only.out} | 6 +- cli/tests/test/{deno_test_only.ts => only.ts} | 6 +- cli/tests/test/pass.out | 15 ++ cli/tests/test/pass.ts | 10 ++ cli/tests/test/quiet.out | 8 ++ cli/tests/test/quiet.ts | 15 ++ cli/tests/test/quiet_test.out | 4 - cli/tests/test/quiet_test.ts | 3 - cli/tests/test/test_finally_cleartimeout.out | 17 --- cli/tests/test/test_runner_test.ts | 19 --- cli/tests/test/unhandled_rejection.out | 10 +- ...ved_promise.out => unresolved_promise.out} | 5 +- ...olved_promise.js => unresolved_promise.ts} | 0 cli/tests/test_type_error/foo_test.ts | 1 - 34 files changed, 447 insertions(+), 170 deletions(-) delete mode 100644 cli/tests/067_test_no_run_type_error.out delete mode 100644 cli/tests/test/deno_test.out delete mode 100644 cli/tests/test/deno_test_fail_fast.out create mode 100644 cli/tests/test/exit_sanitizer.out rename cli/tests/test/{exit_sanitizer_test.ts => exit_sanitizer.ts} (100%) delete mode 100644 cli/tests/test/exit_sanitizer_test.out create mode 100644 cli/tests/test/fail.out create mode 100644 cli/tests/test/fail.ts create mode 100644 cli/tests/test/fail_fast.out create mode 100644 cli/tests/test/fail_fast.ts create mode 100644 cli/tests/test/finally_timeout.out rename cli/tests/test/{test_finally_cleartimeout.ts => finally_timeout.ts} (100%) create mode 100644 cli/tests/test/ignore.out create mode 100644 cli/tests/test/ignore.ts create mode 100644 cli/tests/test/no_check.out create mode 100644 cli/tests/test/no_check.ts rename cli/tests/test/{deno_test_no_color.ts => no_color.ts} (100%) create mode 100644 cli/tests/test/no_run.out create mode 100644 cli/tests/test/no_run.ts rename cli/tests/test/{deno_test_only.ts.out => only.out} (56%) rename cli/tests/test/{deno_test_only.ts => only.ts} (65%) create mode 100644 cli/tests/test/pass.out create mode 100644 cli/tests/test/pass.ts create mode 100644 cli/tests/test/quiet.out create mode 100644 cli/tests/test/quiet.ts delete mode 100644 cli/tests/test/quiet_test.out delete mode 100644 cli/tests/test/quiet_test.ts delete mode 100644 cli/tests/test/test_finally_cleartimeout.out delete mode 100644 cli/tests/test/test_runner_test.ts rename cli/tests/test/{deno_test_unresolved_promise.out => unresolved_promise.out} (64%) rename cli/tests/test/{test_unresolved_promise.js => unresolved_promise.ts} (100%) delete mode 100644 cli/tests/test_type_error/foo_test.ts diff --git a/cli/tests/067_test_no_run_type_error.out b/cli/tests/067_test_no_run_type_error.out deleted file mode 100644 index a09d043483..0000000000 --- a/cli/tests/067_test_no_run_type_error.out +++ /dev/null @@ -1,4 +0,0 @@ -[WILDCARD]error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. -const _a: string = 1; - ~~ - at [WILDCARD]foo_test.ts[WILDCARD] diff --git a/cli/tests/integration/test_tests.rs b/cli/tests/integration/test_tests.rs index ef9fad6791..829dcfbb31 100644 --- a/cli/tests/integration/test_tests.rs +++ b/cli/tests/integration/test_tests.rs @@ -7,7 +7,7 @@ use test_util as util; fn no_color() { let (out, _) = util::run_and_collect_output( false, - "test test/deno_test_no_color.ts", + "test test/no_color.ts", None, Some(vec![("NO_COLOR".to_owned(), "true".to_owned())]), false, @@ -19,10 +19,22 @@ fn no_color() { assert!(out.contains("test result: FAILED. 1 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out")); } -itest!(all { - args: "test test/test_runner_test.ts", +itest!(pass { + args: "test test/pass.ts", + exit_code: 0, + output: "test/pass.out", +}); + +itest!(ignore { + args: "test test/ignore.ts", + exit_code: 0, + output: "test/ignore.out", +}); + +itest!(fail { + args: "test test/fail.ts", exit_code: 1, - output: "test/deno_test.out", + output: "test/fail.out", }); itest!(doc { @@ -31,6 +43,36 @@ itest!(doc { output: "test/doc.out", }); +itest!(quiet { + args: "test --quiet test/quiet.ts", + exit_code: 0, + output: "test/quiet.out", +}); + +itest!(fail_fast { + args: "test --fail-fast test/fail_fast.ts", + exit_code: 1, + output: "test/fail_fast.out", +}); + +itest!(only { + args: "test test/only.ts", + exit_code: 1, + output: "test/only.out", +}); + +itest!(no_check { + args: "test --no-check test/no_check.ts", + exit_code: 1, + output: "test/no_check.out", +}); + +itest!(no_run { + args: "test --unstable --no-run test/no_run.ts", + output: "test/no_run.out", + exit_code: 1, +}); + itest!(allow_all { args: "test --unstable --allow-all test/allow_all.ts", exit_code: 0, @@ -43,34 +85,22 @@ itest!(allow_none { output: "test/allow_none.out", }); -itest!(fail_fast { - args: "test --fail-fast test/test_runner_test.ts", +itest!(exit_sanitizer { + args: "test test/exit_sanitizer.ts", + output: "test/exit_sanitizer.out", exit_code: 1, - output: "test/deno_test_fail_fast.out", }); -itest!(only { - args: "test test/deno_test_only.ts", +itest!(finally_timeout { + args: "test test/finally_timeout.ts", exit_code: 1, - output: "test/deno_test_only.ts.out", -}); - -itest!(no_check { - args: "test --no-check test/test_runner_test.ts", - exit_code: 1, - output: "test/deno_test.out", -}); - -itest!(finally_cleartimeout { - args: "test test/test_finally_cleartimeout.ts", - exit_code: 1, - output: "test/test_finally_cleartimeout.out", + output: "test/finally_timeout.out", }); itest!(unresolved_promise { - args: "test test/test_unresolved_promise.js", + args: "test test/unresolved_promise.ts", exit_code: 1, - output: "test/deno_test_unresolved_promise.out", + output: "test/unresolved_promise.out", }); itest!(unhandled_rejection { @@ -78,21 +108,3 @@ itest!(unhandled_rejection { exit_code: 1, output: "test/unhandled_rejection.out", }); - -itest!(exit_sanitizer { - args: "test test/exit_sanitizer_test.ts", - output: "test/exit_sanitizer_test.out", - exit_code: 1, -}); - -itest!(quiet { - args: "test --quiet test/quiet_test.ts", - exit_code: 0, - output: "test/quiet_test.out", -}); - -itest!(_067_test_no_run_type_error { - args: "test --unstable --no-run test_type_error", - output: "067_test_no_run_type_error.out", - exit_code: 1, -}); diff --git a/cli/tests/test/deno_test.out b/cli/tests/test/deno_test.out deleted file mode 100644 index 18ca1c4e8a..0000000000 --- a/cli/tests/test/deno_test.out +++ /dev/null @@ -1,26 +0,0 @@ -[WILDCARD] -running 4 tests from [WILDCARD] -test fail1 ... FAILED [WILDCARD] -test fail2 ... FAILED [WILDCARD] -test success1 ... ok [WILDCARD] -test fail3 ... FAILED [WILDCARD] - -failures: - -fail1 -AssertionError: fail1 assertion -[WILDCARD] - -fail2 -AssertionError: fail2 assertion -[WILDCARD] - -fail3 -AssertionError: fail3 assertion -[WILDCARD] - -failures: -[WILDCARD] - -test result: FAILED. 1 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out [WILDCARD] - diff --git a/cli/tests/test/deno_test_fail_fast.out b/cli/tests/test/deno_test_fail_fast.out deleted file mode 100644 index ea0d9d369c..0000000000 --- a/cli/tests/test/deno_test_fail_fast.out +++ /dev/null @@ -1,15 +0,0 @@ -[WILDCARD] -running 4 tests from [WILDCARD] -test fail1 ... FAILED [WILDCARD] - -failures: - -fail1 -AssertionError: fail1 assertion -[WILDCARD] - -failures: -[WILDCARD] - -test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out [WILDCARD] - diff --git a/cli/tests/test/exit_sanitizer.out b/cli/tests/test/exit_sanitizer.out new file mode 100644 index 0000000000..186317c781 --- /dev/null +++ b/cli/tests/test/exit_sanitizer.out @@ -0,0 +1,55 @@ +Check [WILDCARD]/test/exit_sanitizer.ts +running 3 tests from [WILDCARD]/test/exit_sanitizer.ts +test exit(0) ... FAILED ([WILDCARD]) +test exit(1) ... FAILED ([WILDCARD]) +test exit(2) ... FAILED ([WILDCARD]) + +failures: + +exit(0) +AssertionError: Test case attempted to exit with exit code: 0 + at assert (deno:runtime/js/06_util.js:33:13) + at deno:runtime/js/40_testing.js:78:9 + at Object.exit (deno:runtime/js/30_os.js:48:7) + at [WILDCARD]/test/exit_sanitizer.ts:2:8 + at asyncOpSanitizer (deno:runtime/js/40_testing.js:21:15) + at resourceSanitizer (deno:runtime/js/40_testing.js:58:13) + at exitSanitizer (deno:runtime/js/40_testing.js:85:15) + at runTest (deno:runtime/js/40_testing.js:199:13) + at Object.runTests (deno:runtime/js/40_testing.js:244:13) + at [WILDCARD]/$deno$test.js:1:27 + +exit(1) +AssertionError: Test case attempted to exit with exit code: 1 + at assert (deno:runtime/js/06_util.js:33:13) + at deno:runtime/js/40_testing.js:78:9 + at Object.exit (deno:runtime/js/30_os.js:48:7) + at [WILDCARD]/test/exit_sanitizer.ts:6:8 + at asyncOpSanitizer (deno:runtime/js/40_testing.js:21:15) + at resourceSanitizer (deno:runtime/js/40_testing.js:58:13) + at exitSanitizer (deno:runtime/js/40_testing.js:85:15) + at runTest (deno:runtime/js/40_testing.js:199:13) + at Object.runTests (deno:runtime/js/40_testing.js:244:13) + at async [WILDCARD]/$deno$test.js:1:1 + +exit(2) +AssertionError: Test case attempted to exit with exit code: 2 + at assert (deno:runtime/js/06_util.js:33:13) + at deno:runtime/js/40_testing.js:78:9 + at Object.exit (deno:runtime/js/30_os.js:48:7) + at [WILDCARD]/test/exit_sanitizer.ts:10:8 + at asyncOpSanitizer (deno:runtime/js/40_testing.js:21:15) + at resourceSanitizer (deno:runtime/js/40_testing.js:58:13) + at exitSanitizer (deno:runtime/js/40_testing.js:85:15) + at runTest (deno:runtime/js/40_testing.js:199:13) + at Object.runTests (deno:runtime/js/40_testing.js:244:13) + at async [WILDCARD]/$deno$test.js:1:1 + +failures: + + exit(0) + exit(1) + exit(2) + +test result: FAILED. 0 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) + diff --git a/cli/tests/test/exit_sanitizer_test.ts b/cli/tests/test/exit_sanitizer.ts similarity index 100% rename from cli/tests/test/exit_sanitizer_test.ts rename to cli/tests/test/exit_sanitizer.ts diff --git a/cli/tests/test/exit_sanitizer_test.out b/cli/tests/test/exit_sanitizer_test.out deleted file mode 100644 index 3161c45ab5..0000000000 --- a/cli/tests/test/exit_sanitizer_test.out +++ /dev/null @@ -1,28 +0,0 @@ -Check [WILDCARD]/exit_sanitizer_test.ts -running 3 tests from [WILDCARD] -test exit(0) ... FAILED ([WILDCARD]) -test exit(1) ... FAILED ([WILDCARD]) -test exit(2) ... FAILED ([WILDCARD]) - -failures: - -exit(0) -AssertionError: Test case attempted to exit with exit code: 0 - [WILDCARD] - -exit(1) -AssertionError: Test case attempted to exit with exit code: 1 - [WILDCARD] - -exit(2) -AssertionError: Test case attempted to exit with exit code: 2 - [WILDCARD] - -failures: - - exit(0) - exit(1) - exit(2) - -test result: FAILED. 0 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) - diff --git a/cli/tests/test/fail.out b/cli/tests/test/fail.out new file mode 100644 index 0000000000..a0ac0203ad --- /dev/null +++ b/cli/tests/test/fail.out @@ -0,0 +1,130 @@ +Check [WILDCARD]/test/fail.ts +running 10 tests from [WILDCARD]/test/fail.ts +test test 0 ... FAILED ([WILDCARD]) +test test 1 ... FAILED ([WILDCARD]) +test test 2 ... FAILED ([WILDCARD]) +test test 3 ... FAILED ([WILDCARD]) +test test 4 ... FAILED ([WILDCARD]) +test test 5 ... FAILED ([WILDCARD]) +test test 6 ... FAILED ([WILDCARD]) +test test 7 ... FAILED ([WILDCARD]) +test test 8 ... FAILED ([WILDCARD]) +test test 9 ... FAILED ([WILDCARD]) + +failures: + +test 0 +Error + at [WILDCARD]/test/fail.ts:2:9 + at asyncOpSanitizer (deno:runtime/js/40_testing.js:21:15) + at resourceSanitizer (deno:runtime/js/40_testing.js:58:13) + at exitSanitizer (deno:runtime/js/40_testing.js:85:15) + at runTest (deno:runtime/js/40_testing.js:199:13) + at Object.runTests (deno:runtime/js/40_testing.js:244:13) + at [WILDCARD]/$deno$test.js:1:27 + +test 1 +Error + at [WILDCARD]/test/fail.ts:5:9 + at asyncOpSanitizer (deno:runtime/js/40_testing.js:21:15) + at resourceSanitizer (deno:runtime/js/40_testing.js:58:13) + at exitSanitizer (deno:runtime/js/40_testing.js:85:15) + at runTest (deno:runtime/js/40_testing.js:199:13) + at Object.runTests (deno:runtime/js/40_testing.js:244:13) + at async [WILDCARD]/$deno$test.js:1:1 + +test 2 +Error + at [WILDCARD]/test/fail.ts:8:9 + at asyncOpSanitizer (deno:runtime/js/40_testing.js:21:15) + at resourceSanitizer (deno:runtime/js/40_testing.js:58:13) + at exitSanitizer (deno:runtime/js/40_testing.js:85:15) + at runTest (deno:runtime/js/40_testing.js:199:13) + at Object.runTests (deno:runtime/js/40_testing.js:244:13) + at async [WILDCARD]/$deno$test.js:1:1 + +test 3 +Error + at [WILDCARD]/test/fail.ts:11:9 + at asyncOpSanitizer (deno:runtime/js/40_testing.js:21:15) + at resourceSanitizer (deno:runtime/js/40_testing.js:58:13) + at exitSanitizer (deno:runtime/js/40_testing.js:85:15) + at runTest (deno:runtime/js/40_testing.js:199:13) + at Object.runTests (deno:runtime/js/40_testing.js:244:13) + at async [WILDCARD]/$deno$test.js:1:1 + +test 4 +Error + at [WILDCARD]/test/fail.ts:14:9 + at asyncOpSanitizer (deno:runtime/js/40_testing.js:21:15) + at resourceSanitizer (deno:runtime/js/40_testing.js:58:13) + at exitSanitizer (deno:runtime/js/40_testing.js:85:15) + at runTest (deno:runtime/js/40_testing.js:199:13) + at Object.runTests (deno:runtime/js/40_testing.js:244:13) + at async [WILDCARD]/$deno$test.js:1:1 + +test 5 +Error + at [WILDCARD]/test/fail.ts:17:9 + at asyncOpSanitizer (deno:runtime/js/40_testing.js:21:15) + at resourceSanitizer (deno:runtime/js/40_testing.js:58:13) + at exitSanitizer (deno:runtime/js/40_testing.js:85:15) + at runTest (deno:runtime/js/40_testing.js:199:13) + at Object.runTests (deno:runtime/js/40_testing.js:244:13) + at async [WILDCARD]/$deno$test.js:1:1 + +test 6 +Error + at [WILDCARD]/test/fail.ts:20:9 + at asyncOpSanitizer (deno:runtime/js/40_testing.js:21:15) + at resourceSanitizer (deno:runtime/js/40_testing.js:58:13) + at exitSanitizer (deno:runtime/js/40_testing.js:85:15) + at runTest (deno:runtime/js/40_testing.js:199:13) + at Object.runTests (deno:runtime/js/40_testing.js:244:13) + at async [WILDCARD]/$deno$test.js:1:1 + +test 7 +Error + at [WILDCARD]/test/fail.ts:23:9 + at asyncOpSanitizer (deno:runtime/js/40_testing.js:21:15) + at resourceSanitizer (deno:runtime/js/40_testing.js:58:13) + at exitSanitizer (deno:runtime/js/40_testing.js:85:15) + at runTest (deno:runtime/js/40_testing.js:199:13) + at Object.runTests (deno:runtime/js/40_testing.js:244:13) + at async [WILDCARD]/$deno$test.js:1:1 + +test 8 +Error + at [WILDCARD]/test/fail.ts:26:9 + at asyncOpSanitizer (deno:runtime/js/40_testing.js:21:15) + at resourceSanitizer (deno:runtime/js/40_testing.js:58:13) + at exitSanitizer (deno:runtime/js/40_testing.js:85:15) + at runTest (deno:runtime/js/40_testing.js:199:13) + at Object.runTests (deno:runtime/js/40_testing.js:244:13) + at async [WILDCARD]/$deno$test.js:1:1 + +test 9 +Error + at [WILDCARD]/test/fail.ts:29:9 + at asyncOpSanitizer (deno:runtime/js/40_testing.js:21:15) + at resourceSanitizer (deno:runtime/js/40_testing.js:58:13) + at exitSanitizer (deno:runtime/js/40_testing.js:85:15) + at runTest (deno:runtime/js/40_testing.js:199:13) + at Object.runTests (deno:runtime/js/40_testing.js:244:13) + at async [WILDCARD]/$deno$test.js:1:1 + +failures: + + test 0 + test 1 + test 2 + test 3 + test 4 + test 5 + test 6 + test 7 + test 8 + test 9 + +test result: FAILED. 0 passed; 10 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) + diff --git a/cli/tests/test/fail.ts b/cli/tests/test/fail.ts new file mode 100644 index 0000000000..9340db5569 --- /dev/null +++ b/cli/tests/test/fail.ts @@ -0,0 +1,30 @@ +Deno.test("test 0", () => { + throw new Error(); +}); +Deno.test("test 1", () => { + throw new Error(); +}); +Deno.test("test 2", () => { + throw new Error(); +}); +Deno.test("test 3", () => { + throw new Error(); +}); +Deno.test("test 4", () => { + throw new Error(); +}); +Deno.test("test 5", () => { + throw new Error(); +}); +Deno.test("test 6", () => { + throw new Error(); +}); +Deno.test("test 7", () => { + throw new Error(); +}); +Deno.test("test 8", () => { + throw new Error(); +}); +Deno.test("test 9", () => { + throw new Error(); +}); diff --git a/cli/tests/test/fail_fast.out b/cli/tests/test/fail_fast.out new file mode 100644 index 0000000000..abc3f0a388 --- /dev/null +++ b/cli/tests/test/fail_fast.out @@ -0,0 +1,22 @@ +Check [WILDCARD]/test/fail_fast.ts +running 10 tests from [WILDCARD]/test/fail_fast.ts +test test 1 ... FAILED ([WILDCARD]) + +failures: + +test 1 +Error + at [WILDCARD]/test/fail_fast.ts:2:9 + at asyncOpSanitizer (deno:runtime/js/40_testing.js:21:15) + at resourceSanitizer (deno:runtime/js/40_testing.js:58:13) + at exitSanitizer (deno:runtime/js/40_testing.js:85:15) + at runTest (deno:runtime/js/40_testing.js:199:13) + at Object.runTests (deno:runtime/js/40_testing.js:244:13) + at [WILDCARD]/$deno$test.js:1:27 + +failures: + + test 1 + +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) + diff --git a/cli/tests/test/fail_fast.ts b/cli/tests/test/fail_fast.ts new file mode 100644 index 0000000000..637e825ece --- /dev/null +++ b/cli/tests/test/fail_fast.ts @@ -0,0 +1,30 @@ +Deno.test("test 1", () => { + throw new Error(); +}); +Deno.test("test 2", () => { + throw new Error(); +}); +Deno.test("test 3", () => { + throw new Error(); +}); +Deno.test("test 4", () => { + throw new Error(); +}); +Deno.test("test 5", () => { + throw new Error(); +}); +Deno.test("test 6", () => { + throw new Error(); +}); +Deno.test("test 7", () => { + throw new Error(); +}); +Deno.test("test 8", () => { + throw new Error(); +}); +Deno.test("test 9", () => { + throw new Error(); +}); +Deno.test("test 0", () => { + throw new Error(); +}); diff --git a/cli/tests/test/finally_timeout.out b/cli/tests/test/finally_timeout.out new file mode 100644 index 0000000000..e652194e5f --- /dev/null +++ b/cli/tests/test/finally_timeout.out @@ -0,0 +1,23 @@ +Check [WILDCARD]/test/finally_timeout.ts +running 2 tests from [WILDCARD]/test/finally_timeout.ts +test error ... FAILED ([WILDCARD]) +test success ... ok ([WILDCARD]) + +failures: + +error +Error: fail + at [WILDCARD]/test/finally_timeout.ts:4:11 + at asyncOpSanitizer (deno:runtime/js/40_testing.js:21:15) + at resourceSanitizer (deno:runtime/js/40_testing.js:58:13) + at exitSanitizer (deno:runtime/js/40_testing.js:85:15) + at runTest (deno:runtime/js/40_testing.js:199:13) + at Object.runTests (deno:runtime/js/40_testing.js:244:13) + at [WILDCARD]/$deno$test.js:1:27 + +failures: + + error + +test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) + diff --git a/cli/tests/test/test_finally_cleartimeout.ts b/cli/tests/test/finally_timeout.ts similarity index 100% rename from cli/tests/test/test_finally_cleartimeout.ts rename to cli/tests/test/finally_timeout.ts diff --git a/cli/tests/test/ignore.out b/cli/tests/test/ignore.out new file mode 100644 index 0000000000..a7c68261d9 --- /dev/null +++ b/cli/tests/test/ignore.out @@ -0,0 +1,15 @@ +Check [WILDCARD]/test/ignore.ts +running 10 tests from [WILDCARD]/test/ignore.ts +test test 0 ... ignored ([WILDCARD]) +test test 1 ... ignored ([WILDCARD]) +test test 2 ... ignored ([WILDCARD]) +test test 3 ... ignored ([WILDCARD]) +test test 4 ... ignored ([WILDCARD]) +test test 5 ... ignored ([WILDCARD]) +test test 6 ... ignored ([WILDCARD]) +test test 7 ... ignored ([WILDCARD]) +test test 8 ... ignored ([WILDCARD]) +test test 9 ... ignored ([WILDCARD]) + +test result: ok. 0 passed; 0 failed; 10 ignored; 0 measured; 0 filtered out ([WILDCARD]) + diff --git a/cli/tests/test/ignore.ts b/cli/tests/test/ignore.ts new file mode 100644 index 0000000000..01113a1291 --- /dev/null +++ b/cli/tests/test/ignore.ts @@ -0,0 +1,9 @@ +for (let i = 0; i < 10; i++) { + Deno.test({ + name: `test ${i}`, + ignore: true, + fn() { + throw new Error("unreachable"); + }, + }); +} diff --git a/cli/tests/test/no_check.out b/cli/tests/test/no_check.out new file mode 100644 index 0000000000..b457bd1dd4 --- /dev/null +++ b/cli/tests/test/no_check.out @@ -0,0 +1,8 @@ + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) + +error: Uncaught TypeError: Cannot read property 'fn' of undefined +Deno.test(); + ^ + at Object.test (deno:runtime/js/40_testing.js:121:14) + at [WILDCARD]/test/no_check.ts:1:6 diff --git a/cli/tests/test/no_check.ts b/cli/tests/test/no_check.ts new file mode 100644 index 0000000000..79d75f9898 --- /dev/null +++ b/cli/tests/test/no_check.ts @@ -0,0 +1 @@ +Deno.test(); diff --git a/cli/tests/test/deno_test_no_color.ts b/cli/tests/test/no_color.ts similarity index 100% rename from cli/tests/test/deno_test_no_color.ts rename to cli/tests/test/no_color.ts diff --git a/cli/tests/test/no_run.out b/cli/tests/test/no_run.out new file mode 100644 index 0000000000..5edf03fe0f --- /dev/null +++ b/cli/tests/test/no_run.out @@ -0,0 +1,5 @@ +Check [WILDCARD]/test/no_run.ts +error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. +const _value: string = 1; + ~~~~~~ + at [WILDCARD]/test/no_run.ts:1:7 diff --git a/cli/tests/test/no_run.ts b/cli/tests/test/no_run.ts new file mode 100644 index 0000000000..b75915753b --- /dev/null +++ b/cli/tests/test/no_run.ts @@ -0,0 +1 @@ +const _value: string = 1; diff --git a/cli/tests/test/deno_test_only.ts.out b/cli/tests/test/only.out similarity index 56% rename from cli/tests/test/deno_test_only.ts.out rename to cli/tests/test/only.out index 5be46a5a00..9195ab5aaf 100644 --- a/cli/tests/test/deno_test_only.ts.out +++ b/cli/tests/test/only.out @@ -1,6 +1,6 @@ -[WILDCARD] -running 1 test from [WILDCARD] -test def ... ok ([WILDCARD]) +Check [WILDCARD]/test/only.ts +running 1 test from [WILDCARD]/test/only.ts +test only ... ok ([WILDCARD]) test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out ([WILDCARD]) diff --git a/cli/tests/test/deno_test_only.ts b/cli/tests/test/only.ts similarity index 65% rename from cli/tests/test/deno_test_only.ts rename to cli/tests/test/only.ts index 12425f21fa..03c4dcac33 100644 --- a/cli/tests/test/deno_test_only.ts +++ b/cli/tests/test/only.ts @@ -1,15 +1,15 @@ Deno.test({ - name: "abc", + name: "before", fn() {}, }); Deno.test({ only: true, - name: "def", + name: "only", fn() {}, }); Deno.test({ - name: "ghi", + name: "after", fn() {}, }); diff --git a/cli/tests/test/pass.out b/cli/tests/test/pass.out new file mode 100644 index 0000000000..cf81ac2e7f --- /dev/null +++ b/cli/tests/test/pass.out @@ -0,0 +1,15 @@ +Check [WILDCARD]/test/pass.ts +running 10 tests from [WILDCARD]/test/pass.ts +test test 0 ... ok ([WILDCARD]) +test test 1 ... ok ([WILDCARD]) +test test 2 ... ok ([WILDCARD]) +test test 3 ... ok ([WILDCARD]) +test test 4 ... ok ([WILDCARD]) +test test 5 ... ok ([WILDCARD]) +test test 6 ... ok ([WILDCARD]) +test test 7 ... ok ([WILDCARD]) +test test 8 ... ok ([WILDCARD]) +test test 9 ... ok ([WILDCARD]) + +test result: ok. 10 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) + diff --git a/cli/tests/test/pass.ts b/cli/tests/test/pass.ts new file mode 100644 index 0000000000..288cc7c83e --- /dev/null +++ b/cli/tests/test/pass.ts @@ -0,0 +1,10 @@ +Deno.test("test 0", () => {}); +Deno.test("test 1", () => {}); +Deno.test("test 2", () => {}); +Deno.test("test 3", () => {}); +Deno.test("test 4", () => {}); +Deno.test("test 5", () => {}); +Deno.test("test 6", () => {}); +Deno.test("test 7", () => {}); +Deno.test("test 8", () => {}); +Deno.test("test 9", () => {}); diff --git a/cli/tests/test/quiet.out b/cli/tests/test/quiet.out new file mode 100644 index 0000000000..05302fb2ce --- /dev/null +++ b/cli/tests/test/quiet.out @@ -0,0 +1,8 @@ +running 4 tests from [WILDCARD]/test/quiet.ts +test console.log ... ok ([WILDCARD]) +test console.error ... ok ([WILDCARD]) +test console.info ... ok ([WILDCARD]) +test console.warn ... ok ([WILDCARD]) + +test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) + diff --git a/cli/tests/test/quiet.ts b/cli/tests/test/quiet.ts new file mode 100644 index 0000000000..f40805bfbd --- /dev/null +++ b/cli/tests/test/quiet.ts @@ -0,0 +1,15 @@ +Deno.test("console.log", function () { + console.log("log"); +}); + +Deno.test("console.error", function () { + console.error("error"); +}); + +Deno.test("console.info", function () { + console.info("info"); +}); + +Deno.test("console.warn", function () { + console.info("warn"); +}); diff --git a/cli/tests/test/quiet_test.out b/cli/tests/test/quiet_test.out deleted file mode 100644 index 61d719d840..0000000000 --- a/cli/tests/test/quiet_test.out +++ /dev/null @@ -1,4 +0,0 @@ -running 1 test from [WILDCARD] -test log ... ok [WILDCARD] - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out [WILDCARD] diff --git a/cli/tests/test/quiet_test.ts b/cli/tests/test/quiet_test.ts deleted file mode 100644 index e98e6797aa..0000000000 --- a/cli/tests/test/quiet_test.ts +++ /dev/null @@ -1,3 +0,0 @@ -Deno.test("log", function () { - console.log("log"); -}); diff --git a/cli/tests/test/test_finally_cleartimeout.out b/cli/tests/test/test_finally_cleartimeout.out deleted file mode 100644 index 1c4d62b4ec..0000000000 --- a/cli/tests/test/test_finally_cleartimeout.out +++ /dev/null @@ -1,17 +0,0 @@ -Check [WILDCARD]/test_finally_cleartimeout.ts -running 2 tests from [WILDCARD] -test error ... FAILED ([WILDCARD]) -test success ... ok ([WILDCARD]) - -failures: - -error -Error: fail - [WILDCARD] - -failures: - - error - -test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) - diff --git a/cli/tests/test/test_runner_test.ts b/cli/tests/test/test_runner_test.ts deleted file mode 100644 index 111ff51c74..0000000000 --- a/cli/tests/test/test_runner_test.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - -import { assert } from "../../../test_util/std/testing/asserts.ts"; - -Deno.test("fail1", function () { - assert(false, "fail1 assertion"); -}); - -Deno.test("fail2", function () { - assert(false, "fail2 assertion"); -}); - -Deno.test("success1", function () { - assert(true); -}); - -Deno.test("fail3", function () { - assert(false, "fail3 assertion"); -}); diff --git a/cli/tests/test/unhandled_rejection.out b/cli/tests/test/unhandled_rejection.out index 27b3865a83..fae353a283 100644 --- a/cli/tests/test/unhandled_rejection.out +++ b/cli/tests/test/unhandled_rejection.out @@ -1,6 +1,10 @@ -Check [WILDCARD] +Check [WILDCARD]/test/unhandled_rejection.ts -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out [WILDCARD] +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) error: Uncaught (in promise) Error: rejection -[WILDCARD] + reject(new Error("rejection")); + ^ + at [WILDCARD]/test/unhandled_rejection.ts:2:10 + at new Promise () + at [WILDCARD]/test/unhandled_rejection.ts:1:1 diff --git a/cli/tests/test/deno_test_unresolved_promise.out b/cli/tests/test/unresolved_promise.out similarity index 64% rename from cli/tests/test/deno_test_unresolved_promise.out rename to cli/tests/test/unresolved_promise.out index 249f1d6872..cd505bcbfc 100644 --- a/cli/tests/test/deno_test_unresolved_promise.out +++ b/cli/tests/test/unresolved_promise.out @@ -1,5 +1,6 @@ -running 2 tests from [WILDCARD] +Check [WILDCARD]/test/unresolved_promise.ts +running 2 tests from [WILDCARD]/test/unresolved_promise.ts test unresolved promise ... -test result: FAILED. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out [WILDCARD] +test result: FAILED. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) error: Module evaluation is still pending but there are no pending ops or dynamic imports. This situation is often caused by unresolved promise. diff --git a/cli/tests/test/test_unresolved_promise.js b/cli/tests/test/unresolved_promise.ts similarity index 100% rename from cli/tests/test/test_unresolved_promise.js rename to cli/tests/test/unresolved_promise.ts diff --git a/cli/tests/test_type_error/foo_test.ts b/cli/tests/test_type_error/foo_test.ts deleted file mode 100644 index 4b9404558b..0000000000 --- a/cli/tests/test_type_error/foo_test.ts +++ /dev/null @@ -1 +0,0 @@ -const _a: string = 1;