From 62f33e3b146da2f4264d6fa71409516de892bdf3 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Mon, 1 Mar 2021 20:02:51 +0800 Subject: test(cli): reorganize test subcommand testcases and fixtures (#9627) --- cli/tests/deno_test.out | 26 ------ cli/tests/deno_test_fail_fast.out | 15 ---- cli/tests/deno_test_no_color.ts | 17 ---- cli/tests/deno_test_only.ts | 15 ---- cli/tests/deno_test_only.ts.out | 7 -- cli/tests/deno_test_unresolved_promise.out | 4 - cli/tests/exit_sanitizer_test.out | 28 ------ cli/tests/exit_sanitizer_test.ts | 11 --- cli/tests/integration_tests.rs | 108 ++++++++++++------------ 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 | 7 ++ cli/tests/test/deno_test_unresolved_promise.out | 4 + cli/tests/test/exit_sanitizer_test.out | 28 ++++++ cli/tests/test/exit_sanitizer_test.ts | 11 +++ 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 | 15 ++++ cli/tests/test_finally_cleartimeout.out | 17 ---- cli/tests/test_finally_cleartimeout.ts | 11 --- cli/tests/test_runner_test.ts | 19 ----- cli/tests/test_unresolved_promise.js | 15 ---- 25 files changed, 241 insertions(+), 237 deletions(-) delete mode 100644 cli/tests/deno_test.out delete mode 100644 cli/tests/deno_test_fail_fast.out delete mode 100644 cli/tests/deno_test_no_color.ts delete mode 100644 cli/tests/deno_test_only.ts delete mode 100644 cli/tests/deno_test_only.ts.out delete mode 100644 cli/tests/deno_test_unresolved_promise.out delete mode 100644 cli/tests/exit_sanitizer_test.out delete mode 100644 cli/tests/exit_sanitizer_test.ts create mode 100644 cli/tests/test/deno_test.out create mode 100644 cli/tests/test/deno_test_fail_fast.out create mode 100644 cli/tests/test/deno_test_no_color.ts create mode 100644 cli/tests/test/deno_test_only.ts create mode 100644 cli/tests/test/deno_test_only.ts.out create mode 100644 cli/tests/test/deno_test_unresolved_promise.out create mode 100644 cli/tests/test/exit_sanitizer_test.out create mode 100644 cli/tests/test/exit_sanitizer_test.ts create mode 100644 cli/tests/test/test_finally_cleartimeout.out create mode 100644 cli/tests/test/test_finally_cleartimeout.ts create mode 100644 cli/tests/test/test_runner_test.ts create mode 100644 cli/tests/test/test_unresolved_promise.js delete mode 100644 cli/tests/test_finally_cleartimeout.out delete mode 100644 cli/tests/test_finally_cleartimeout.ts delete mode 100644 cli/tests/test_runner_test.ts delete mode 100644 cli/tests/test_unresolved_promise.js (limited to 'cli') diff --git a/cli/tests/deno_test.out b/cli/tests/deno_test.out deleted file mode 100644 index 338f804ed..000000000 --- a/cli/tests/deno_test.out +++ /dev/null @@ -1,26 +0,0 @@ -[WILDCARD] -running 4 tests -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/deno_test_fail_fast.out b/cli/tests/deno_test_fail_fast.out deleted file mode 100644 index 9fb82c1c6..000000000 --- a/cli/tests/deno_test_fail_fast.out +++ /dev/null @@ -1,15 +0,0 @@ -[WILDCARD] -running 4 tests -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/deno_test_no_color.ts b/cli/tests/deno_test_no_color.ts deleted file mode 100644 index 38c531ee9..000000000 --- a/cli/tests/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/deno_test_only.ts b/cli/tests/deno_test_only.ts deleted file mode 100644 index 12425f21f..000000000 --- a/cli/tests/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/deno_test_only.ts.out b/cli/tests/deno_test_only.ts.out deleted file mode 100644 index a23f2505c..000000000 --- a/cli/tests/deno_test_only.ts.out +++ /dev/null @@ -1,7 +0,0 @@ -[WILDCARD]running 1 tests -test def ... ok ([WILDCARD]) - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) - -FAILED because the "only" option was used - diff --git a/cli/tests/deno_test_unresolved_promise.out b/cli/tests/deno_test_unresolved_promise.out deleted file mode 100644 index cc4f2985e..000000000 --- a/cli/tests/deno_test_unresolved_promise.out +++ /dev/null @@ -1,4 +0,0 @@ -Check [WILDCARD] -running 2 tests -test unresolved promise ... in promise -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/exit_sanitizer_test.out b/cli/tests/exit_sanitizer_test.out deleted file mode 100644 index 351453928..000000000 --- a/cli/tests/exit_sanitizer_test.out +++ /dev/null @@ -1,28 +0,0 @@ -Check [WILDCARD]/$deno$test.ts -running 3 tests -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/exit_sanitizer_test.ts b/cli/tests/exit_sanitizer_test.ts deleted file mode 100644 index 186406a9d..000000000 --- a/cli/tests/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/integration_tests.rs b/cli/tests/integration_tests.rs index 0d076f180..d07fe1b22 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -2238,28 +2238,6 @@ mod integration { } } - #[test] - fn deno_test_no_color() { - let (out, _) = util::run_and_collect_output( - false, - "test deno_test_no_color.ts", - None, - Some(vec![("NO_COLOR".to_owned(), "true".to_owned())]), - false, - ); - // ANSI escape codes should be stripped. - assert!(out.contains("test success ... ok")); - assert!(out.contains("test fail ... FAILED")); - assert!(out.contains("test ignored ... ignored")); - assert!(out.contains("test result: FAILED. 1 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out")); - } - - itest!(test_exit_sanitizer { - args: "test exit_sanitizer_test.ts", - output: "exit_sanitizer_test.out", - exit_code: 1, - }); - itest!(stdout_write_all { args: "run --quiet stdout_write_all.ts", output: "stdout_write_all.out", @@ -2386,41 +2364,67 @@ mod integration { http_server: true, }); - itest!(deno_test { - args: "test test_runner_test.ts", - exit_code: 1, - output: "deno_test.out", - }); + mod test { + use super::*; - itest!(deno_test_fail_fast { - args: "test --fail-fast test_runner_test.ts", - exit_code: 1, - output: "deno_test_fail_fast.out", - }); + #[test] + fn no_color() { + let (out, _) = util::run_and_collect_output( + false, + "test test/deno_test_no_color.ts", + None, + Some(vec![("NO_COLOR".to_owned(), "true".to_owned())]), + false, + ); + // ANSI escape codes should be stripped. + assert!(out.contains("test success ... ok")); + assert!(out.contains("test fail ... FAILED")); + assert!(out.contains("test ignored ... ignored")); + assert!(out.contains("test result: FAILED. 1 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out")); + } - itest!(deno_test_only { - args: "test deno_test_only.ts", - exit_code: 1, - output: "deno_test_only.ts.out", - }); + itest!(all { + args: "test test/test_runner_test.ts", + exit_code: 1, + output: "test/deno_test.out", + }); - itest!(deno_test_no_check { - args: "test --no-check test_runner_test.ts", - exit_code: 1, - output: "deno_test.out", - }); + itest!(fail_fast { + args: "test --fail-fast test/test_runner_test.ts", + exit_code: 1, + output: "test/deno_test_fail_fast.out", + }); - itest!(deno_test_finally_cleartimeout { - args: "test test_finally_cleartimeout.ts", - exit_code: 1, - output: "test_finally_cleartimeout.out", - }); + itest!(only { + args: "test test/deno_test_only.ts", + exit_code: 1, + output: "test/deno_test_only.ts.out", + }); - itest!(deno_test_unresolved_promise { - args: "test test_unresolved_promise.js", - exit_code: 1, - output: "deno_test_unresolved_promise.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", + }); + + itest!(unresolved_promise { + args: "test test/test_unresolved_promise.js", + exit_code: 1, + output: "test/deno_test_unresolved_promise.out", + }); + + itest!(exit_sanitizer { + args: "test test/exit_sanitizer_test.ts", + output: "test/exit_sanitizer_test.out", + exit_code: 1, + }); + } #[test] fn timeout_clear() { diff --git a/cli/tests/test/deno_test.out b/cli/tests/test/deno_test.out new file mode 100644 index 000000000..338f804ed --- /dev/null +++ b/cli/tests/test/deno_test.out @@ -0,0 +1,26 @@ +[WILDCARD] +running 4 tests +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 new file mode 100644 index 000000000..9fb82c1c6 --- /dev/null +++ b/cli/tests/test/deno_test_fail_fast.out @@ -0,0 +1,15 @@ +[WILDCARD] +running 4 tests +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 new file mode 100644 index 000000000..38c531ee9 --- /dev/null +++ b/cli/tests/test/deno_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/deno_test_only.ts b/cli/tests/test/deno_test_only.ts new file mode 100644 index 000000000..12425f21f --- /dev/null +++ b/cli/tests/test/deno_test_only.ts @@ -0,0 +1,15 @@ +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 new file mode 100644 index 000000000..a23f2505c --- /dev/null +++ b/cli/tests/test/deno_test_only.ts.out @@ -0,0 +1,7 @@ +[WILDCARD]running 1 tests +test def ... ok ([WILDCARD]) + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 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 new file mode 100644 index 000000000..cc4f2985e --- /dev/null +++ b/cli/tests/test/deno_test_unresolved_promise.out @@ -0,0 +1,4 @@ +Check [WILDCARD] +running 2 tests +test unresolved promise ... in promise +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_test.out b/cli/tests/test/exit_sanitizer_test.out new file mode 100644 index 000000000..351453928 --- /dev/null +++ b/cli/tests/test/exit_sanitizer_test.out @@ -0,0 +1,28 @@ +Check [WILDCARD]/$deno$test.ts +running 3 tests +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 new file mode 100644 index 000000000..186406a9d --- /dev/null +++ b/cli/tests/test/exit_sanitizer_test.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/test_finally_cleartimeout.out b/cli/tests/test/test_finally_cleartimeout.out new file mode 100644 index 000000000..c88b8242b --- /dev/null +++ b/cli/tests/test/test_finally_cleartimeout.out @@ -0,0 +1,17 @@ +Check [WILDCARD]/$deno$test.ts +running 2 tests +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 new file mode 100644 index 000000000..dcc0a4d64 --- /dev/null +++ b/cli/tests/test/test_finally_cleartimeout.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/test_runner_test.ts b/cli/tests/test/test_runner_test.ts new file mode 100644 index 000000000..111ff51c7 --- /dev/null +++ b/cli/tests/test/test_runner_test.ts @@ -0,0 +1,19 @@ +// 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 new file mode 100644 index 000000000..466b18864 --- /dev/null +++ b/cli/tests/test/test_unresolved_promise.js @@ -0,0 +1,15 @@ +Deno.test({ + name: "unresolved promise", + fn() { + return new Promise((_resolve, _reject) => { + console.log("in promise"); + }); + }, +}); + +Deno.test({ + name: "ok", + fn() { + console.log("ok test"); + }, +}); diff --git a/cli/tests/test_finally_cleartimeout.out b/cli/tests/test_finally_cleartimeout.out deleted file mode 100644 index c88b8242b..000000000 --- a/cli/tests/test_finally_cleartimeout.out +++ /dev/null @@ -1,17 +0,0 @@ -Check [WILDCARD]/$deno$test.ts -running 2 tests -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_finally_cleartimeout.ts b/cli/tests/test_finally_cleartimeout.ts deleted file mode 100644 index dcc0a4d64..000000000 --- a/cli/tests/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_runner_test.ts b/cli/tests/test_runner_test.ts deleted file mode 100644 index 08b69a0a6..000000000 --- a/cli/tests/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_unresolved_promise.js b/cli/tests/test_unresolved_promise.js deleted file mode 100644 index 466b18864..000000000 --- a/cli/tests/test_unresolved_promise.js +++ /dev/null @@ -1,15 +0,0 @@ -Deno.test({ - name: "unresolved promise", - fn() { - return new Promise((_resolve, _reject) => { - console.log("in promise"); - }); - }, -}); - -Deno.test({ - name: "ok", - fn() { - console.log("ok test"); - }, -}); -- cgit v1.2.3