From a0c0daac24c496e49e7c0abaae12f34723785a7d Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Tue, 29 Jun 2021 21:40:16 +0800 Subject: test(cli): harden test runner tests (#11166) --- cli/tests/067_test_no_run_type_error.out | 4 - cli/tests/integration/test_tests.rs | 88 +++++++++------- cli/tests/test/deno_test.out | 26 ----- cli/tests/test/deno_test_fail_fast.out | 15 --- cli/tests/test/deno_test_no_color.ts | 17 ---- cli/tests/test/deno_test_only.ts | 15 --- cli/tests/test/deno_test_only.ts.out | 8 -- cli/tests/test/deno_test_unresolved_promise.out | 5 - cli/tests/test/exit_sanitizer.out | 55 ++++++++++ cli/tests/test/exit_sanitizer.ts | 11 ++ cli/tests/test/exit_sanitizer_test.out | 28 ----- cli/tests/test/exit_sanitizer_test.ts | 11 -- 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 +++++ cli/tests/test/finally_timeout.ts | 11 ++ 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 + cli/tests/test/no_color.ts | 17 ++++ cli/tests/test/no_run.out | 5 + cli/tests/test/no_run.ts | 1 + cli/tests/test/only.out | 8 ++ cli/tests/test/only.ts | 15 +++ 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_finally_cleartimeout.ts | 11 -- cli/tests/test/test_runner_test.ts | 19 ---- cli/tests/test/test_unresolved_promise.js | 11 -- cli/tests/test/unhandled_rejection.out | 10 +- cli/tests/test/unresolved_promise.out | 6 ++ cli/tests/test/unresolved_promise.ts | 11 ++ cli/tests/test_type_error/foo_test.ts | 1 - 41 files changed, 513 insertions(+), 236 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 delete mode 100644 cli/tests/test/deno_test_no_color.ts delete mode 100644 cli/tests/test/deno_test_only.ts delete mode 100644 cli/tests/test/deno_test_only.ts.out delete mode 100644 cli/tests/test/deno_test_unresolved_promise.out create mode 100644 cli/tests/test/exit_sanitizer.out create mode 100644 cli/tests/test/exit_sanitizer.ts delete mode 100644 cli/tests/test/exit_sanitizer_test.out delete mode 100644 cli/tests/test/exit_sanitizer_test.ts 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 create mode 100644 cli/tests/test/finally_timeout.ts 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 create mode 100644 cli/tests/test/no_color.ts create mode 100644 cli/tests/test/no_run.out create mode 100644 cli/tests/test/no_run.ts create mode 100644 cli/tests/test/only.out create mode 100644 cli/tests/test/only.ts 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_finally_cleartimeout.ts delete mode 100644 cli/tests/test/test_runner_test.ts delete mode 100644 cli/tests/test/test_unresolved_promise.js create mode 100644 cli/tests/test/unresolved_promise.out create mode 100644 cli/tests/test/unresolved_promise.ts delete mode 100644 cli/tests/test_type_error/foo_test.ts (limited to 'cli') 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 a09d04348..000000000 --- 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 ef9fad679..829dcfbb3 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,68 +43,68 @@ itest!(doc { output: "test/doc.out", }); -itest!(allow_all { - args: "test --unstable --allow-all test/allow_all.ts", +itest!(quiet { + args: "test --quiet test/quiet.ts", exit_code: 0, - output: "test/allow_all.out", -}); - -itest!(allow_none { - args: "test --unstable test/allow_none.ts", - exit_code: 1, - output: "test/allow_none.out", + output: "test/quiet.out", }); itest!(fail_fast { - args: "test --fail-fast test/test_runner_test.ts", + args: "test --fail-fast test/fail_fast.ts", exit_code: 1, - output: "test/deno_test_fail_fast.out", + output: "test/fail_fast.out", }); itest!(only { - args: "test test/deno_test_only.ts", + args: "test test/only.ts", exit_code: 1, - output: "test/deno_test_only.ts.out", + output: "test/only.out", }); itest!(no_check { - args: "test --no-check test/test_runner_test.ts", + args: "test --no-check test/no_check.ts", exit_code: 1, - output: "test/deno_test.out", + output: "test/no_check.out", }); -itest!(finally_cleartimeout { - args: "test test/test_finally_cleartimeout.ts", +itest!(no_run { + args: "test --unstable --no-run test/no_run.ts", + output: "test/no_run.out", exit_code: 1, - output: "test/test_finally_cleartimeout.out", }); -itest!(unresolved_promise { - args: "test test/test_unresolved_promise.js", - exit_code: 1, - output: "test/deno_test_unresolved_promise.out", +itest!(allow_all { + args: "test --unstable --allow-all test/allow_all.ts", + exit_code: 0, + output: "test/allow_all.out", }); -itest!(unhandled_rejection { - args: "test test/unhandled_rejection.ts", +itest!(allow_none { + args: "test --unstable test/allow_none.ts", exit_code: 1, - output: "test/unhandled_rejection.out", + output: "test/allow_none.out", }); itest!(exit_sanitizer { - args: "test test/exit_sanitizer_test.ts", - output: "test/exit_sanitizer_test.out", + args: "test test/exit_sanitizer.ts", + output: "test/exit_sanitizer.out", exit_code: 1, }); -itest!(quiet { - args: "test --quiet test/quiet_test.ts", - exit_code: 0, - output: "test/quiet_test.out", +itest!(finally_timeout { + args: "test test/finally_timeout.ts", + exit_code: 1, + output: "test/finally_timeout.out", }); -itest!(_067_test_no_run_type_error { - args: "test --unstable --no-run test_type_error", - output: "067_test_no_run_type_error.out", +itest!(unresolved_promise { + args: "test test/unresolved_promise.ts", exit_code: 1, + output: "test/unresolved_promise.out", +}); + +itest!(unhandled_rejection { + args: "test test/unhandled_rejection.ts", + exit_code: 1, + output: "test/unhandled_rejection.out", }); diff --git a/cli/tests/test/deno_test.out b/cli/tests/test/deno_test.out deleted file mode 100644 index 18ca1c4e8..000000000 --- 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 ea0d9d369..000000000 --- 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/deno_test_no_color.ts b/cli/tests/test/deno_test_no_color.ts deleted file mode 100644 index 38c531ee9..000000000 --- a/cli/tests/test/deno_test_no_color.ts +++ /dev/null @@ -1,17 +0,0 @@ -Deno.test({ - name: "success", - fn() {}, -}); - -Deno.test({ - name: "fail", - fn() { - throw new Error("fail"); - }, -}); - -Deno.test({ - name: "ignored", - ignore: true, - fn() {}, -}); diff --git a/cli/tests/test/deno_test_only.ts b/cli/tests/test/deno_test_only.ts deleted file mode 100644 index 12425f21f..000000000 --- a/cli/tests/test/deno_test_only.ts +++ /dev/null @@ -1,15 +0,0 @@ -Deno.test({ - name: "abc", - fn() {}, -}); - -Deno.test({ - only: true, - name: "def", - fn() {}, -}); - -Deno.test({ - name: "ghi", - fn() {}, -}); diff --git a/cli/tests/test/deno_test_only.ts.out b/cli/tests/test/deno_test_only.ts.out deleted file mode 100644 index 5be46a5a0..000000000 --- a/cli/tests/test/deno_test_only.ts.out +++ /dev/null @@ -1,8 +0,0 @@ -[WILDCARD] -running 1 test from [WILDCARD] -test def ... ok ([WILDCARD]) - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out ([WILDCARD]) - -FAILED because the "only" option was used - diff --git a/cli/tests/test/deno_test_unresolved_promise.out b/cli/tests/test/deno_test_unresolved_promise.out deleted file mode 100644 index 249f1d687..000000000 --- a/cli/tests/test/deno_test_unresolved_promise.out +++ /dev/null @@ -1,5 +0,0 @@ -running 2 tests from [WILDCARD] -test unresolved promise ... -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/exit_sanitizer.out b/cli/tests/test/exit_sanitizer.out new file mode 100644 index 000000000..186317c78 --- /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.ts b/cli/tests/test/exit_sanitizer.ts new file mode 100644 index 000000000..186406a9d --- /dev/null +++ b/cli/tests/test/exit_sanitizer.ts @@ -0,0 +1,11 @@ +Deno.test("exit(0)", function () { + Deno.exit(0); +}); + +Deno.test("exit(1)", function () { + Deno.exit(1); +}); + +Deno.test("exit(2)", function () { + Deno.exit(2); +}); diff --git a/cli/tests/test/exit_sanitizer_test.out b/cli/tests/test/exit_sanitizer_test.out deleted file mode 100644 index 3161c45ab..000000000 --- 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/exit_sanitizer_test.ts b/cli/tests/test/exit_sanitizer_test.ts deleted file mode 100644 index 186406a9d..000000000 --- a/cli/tests/test/exit_sanitizer_test.ts +++ /dev/null @@ -1,11 +0,0 @@ -Deno.test("exit(0)", function () { - Deno.exit(0); -}); - -Deno.test("exit(1)", function () { - Deno.exit(1); -}); - -Deno.test("exit(2)", function () { - Deno.exit(2); -}); diff --git a/cli/tests/test/fail.out b/cli/tests/test/fail.out new file mode 100644 index 000000000..a0ac0203a --- /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 000000000..9340db556 --- /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 000000000..abc3f0a38 --- /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 000000000..637e825ec --- /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 000000000..e652194e5 --- /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/finally_timeout.ts b/cli/tests/test/finally_timeout.ts new file mode 100644 index 000000000..dcc0a4d64 --- /dev/null +++ b/cli/tests/test/finally_timeout.ts @@ -0,0 +1,11 @@ +Deno.test("error", function () { + const timer = setTimeout(() => null, 10000); + try { + throw new Error("fail"); + } finally { + clearTimeout(timer); + } +}); + +Deno.test("success", function () { +}); diff --git a/cli/tests/test/ignore.out b/cli/tests/test/ignore.out new file mode 100644 index 000000000..a7c68261d --- /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 000000000..01113a129 --- /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 000000000..b457bd1dd --- /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 000000000..79d75f989 --- /dev/null +++ b/cli/tests/test/no_check.ts @@ -0,0 +1 @@ +Deno.test(); diff --git a/cli/tests/test/no_color.ts b/cli/tests/test/no_color.ts new file mode 100644 index 000000000..38c531ee9 --- /dev/null +++ b/cli/tests/test/no_color.ts @@ -0,0 +1,17 @@ +Deno.test({ + name: "success", + fn() {}, +}); + +Deno.test({ + name: "fail", + fn() { + throw new Error("fail"); + }, +}); + +Deno.test({ + name: "ignored", + ignore: true, + fn() {}, +}); diff --git a/cli/tests/test/no_run.out b/cli/tests/test/no_run.out new file mode 100644 index 000000000..5edf03fe0 --- /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 000000000..b75915753 --- /dev/null +++ b/cli/tests/test/no_run.ts @@ -0,0 +1 @@ +const _value: string = 1; diff --git a/cli/tests/test/only.out b/cli/tests/test/only.out new file mode 100644 index 000000000..9195ab5aa --- /dev/null +++ b/cli/tests/test/only.out @@ -0,0 +1,8 @@ +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]) + +FAILED because the "only" option was used + diff --git a/cli/tests/test/only.ts b/cli/tests/test/only.ts new file mode 100644 index 000000000..03c4dcac3 --- /dev/null +++ b/cli/tests/test/only.ts @@ -0,0 +1,15 @@ +Deno.test({ + name: "before", + fn() {}, +}); + +Deno.test({ + only: true, + name: "only", + fn() {}, +}); + +Deno.test({ + name: "after", + fn() {}, +}); diff --git a/cli/tests/test/pass.out b/cli/tests/test/pass.out new file mode 100644 index 000000000..cf81ac2e7 --- /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 000000000..288cc7c83 --- /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 000000000..05302fb2c --- /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 000000000..f40805bfb --- /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 61d719d84..000000000 --- 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 e98e6797a..000000000 --- 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 1c4d62b4e..000000000 --- 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_finally_cleartimeout.ts b/cli/tests/test/test_finally_cleartimeout.ts deleted file mode 100644 index dcc0a4d64..000000000 --- a/cli/tests/test/test_finally_cleartimeout.ts +++ /dev/null @@ -1,11 +0,0 @@ -Deno.test("error", function () { - const timer = setTimeout(() => null, 10000); - try { - throw new Error("fail"); - } finally { - clearTimeout(timer); - } -}); - -Deno.test("success", function () { -}); diff --git a/cli/tests/test/test_runner_test.ts b/cli/tests/test/test_runner_test.ts deleted file mode 100644 index 111ff51c7..000000000 --- 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/test_unresolved_promise.js b/cli/tests/test/test_unresolved_promise.js deleted file mode 100644 index 8f50e907a..000000000 --- a/cli/tests/test/test_unresolved_promise.js +++ /dev/null @@ -1,11 +0,0 @@ -Deno.test({ - name: "unresolved promise", - fn() { - return new Promise((_resolve, _reject) => {}); - }, -}); - -Deno.test({ - name: "ok", - fn() {}, -}); diff --git a/cli/tests/test/unhandled_rejection.out b/cli/tests/test/unhandled_rejection.out index 27b3865a8..fae353a28 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/unresolved_promise.out b/cli/tests/test/unresolved_promise.out new file mode 100644 index 000000000..cd505bcbf --- /dev/null +++ b/cli/tests/test/unresolved_promise.out @@ -0,0 +1,6 @@ +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]) + +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/unresolved_promise.ts b/cli/tests/test/unresolved_promise.ts new file mode 100644 index 000000000..8f50e907a --- /dev/null +++ b/cli/tests/test/unresolved_promise.ts @@ -0,0 +1,11 @@ +Deno.test({ + name: "unresolved promise", + fn() { + return new Promise((_resolve, _reject) => {}); + }, +}); + +Deno.test({ + name: "ok", + fn() {}, +}); 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 4b9404558..000000000 --- a/cli/tests/test_type_error/foo_test.ts +++ /dev/null @@ -1 +0,0 @@ -const _a: string = 1; -- cgit v1.2.3