From 623767a0529a17b73f6be38f97df00ef8c61ae3d Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Tue, 14 Jun 2022 13:09:07 +0300 Subject: [PATCH] fix tests for real --- lib/internal/test_runner/test.js | 2 +- test/message/test_runner_no_refs.out | 2 + test/message/test_runner_only_tests.out | 23 ++++++ test/message/test_runner_output.out | 71 +++++++++++++++++++ .../test_runner_unresolved_promise.out | 3 + 5 files changed, 100 insertions(+), 1 deletion(-) diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index e7180ff1df811b..1643acdaa013b1 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -280,7 +280,6 @@ class Test extends AsyncResource { } start() { - this.reporter.subTest(this.indent, this.name); // If there is enough available concurrency to run the test now, then do // it. Otherwise, return a Promise to the caller and mark the test as // pending for later execution. @@ -296,6 +295,7 @@ class Test extends AsyncResource { } async run() { + this.reporter.subTest(this.indent, this.name); this.parent.activeSubtests++; this.startTime = hrtime(); diff --git a/test/message/test_runner_no_refs.out b/test/message/test_runner_no_refs.out index c5407e3bd330c0..078ab7c390e488 100644 --- a/test/message/test_runner_no_refs.out +++ b/test/message/test_runner_no_refs.out @@ -1,4 +1,6 @@ TAP version 13 +# Subtest: does not keep event loop alive + # Subtest: +does not keep event loop alive not ok 1 - +does not keep event loop alive --- duration_ms: * diff --git a/test/message/test_runner_only_tests.out b/test/message/test_runner_only_tests.out index 76e6337bb8953d..b65958b010f8ad 100644 --- a/test/message/test_runner_only_tests.out +++ b/test/message/test_runner_only_tests.out @@ -1,76 +1,97 @@ TAP version 13 +# Subtest: only = undefined ok 1 - only = undefined # SKIP 'only' option not set --- duration_ms: * ... +# Subtest: only = undefined, skip = string ok 2 - only = undefined, skip = string # SKIP 'only' option not set --- duration_ms: * ... +# Subtest: only = undefined, skip = true ok 3 - only = undefined, skip = true # SKIP 'only' option not set --- duration_ms: * ... +# Subtest: only = undefined, skip = false ok 4 - only = undefined, skip = false # SKIP 'only' option not set --- duration_ms: * ... +# Subtest: only = false ok 5 - only = false # SKIP 'only' option not set --- duration_ms: * ... +# Subtest: only = false, skip = string ok 6 - only = false, skip = string # SKIP 'only' option not set --- duration_ms: * ... +# Subtest: only = false, skip = true ok 7 - only = false, skip = true # SKIP 'only' option not set --- duration_ms: * ... +# Subtest: only = false, skip = false ok 8 - only = false, skip = false # SKIP 'only' option not set --- duration_ms: * ... +# Subtest: only = true, skip = string ok 9 - only = true, skip = string # SKIP skip message --- duration_ms: * ... +# Subtest: only = true, skip = true ok 10 - only = true, skip = true # SKIP --- duration_ms: * ... +# Subtest: only = true, with subtests + # Subtest: running subtest 1 ok 1 - running subtest 1 --- duration_ms: * ... + # Subtest: running subtest 2 ok 2 - running subtest 2 --- duration_ms: * ... + # Subtest: skipped subtest 1 ok 3 - skipped subtest 1 # SKIP 'only' option not set --- duration_ms: * ... + # Subtest: skipped subtest 2 ok 4 - skipped subtest 2 # SKIP 'only' option not set --- duration_ms: * ... + # Subtest: running subtest 3 ok 5 - running subtest 3 --- duration_ms: * ... + # Subtest: running subtest 4 + # Subtest: running sub-subtest 1 ok 1 - running sub-subtest 1 --- duration_ms: * ... + # Subtest: running sub-subtest 2 ok 2 - running sub-subtest 2 --- duration_ms: * ... + # Subtest: skipped sub-subtest 1 ok 3 - skipped sub-subtest 1 # SKIP 'only' option not set --- duration_ms: * ... + # Subtest: skipped sub-subtest 2 ok 4 - skipped sub-subtest 2 # SKIP 'only' option not set --- duration_ms: * @@ -80,10 +101,12 @@ ok 10 - only = true, skip = true # SKIP --- duration_ms: * ... + # Subtest: skipped subtest 3 ok 7 - skipped subtest 3 # SKIP 'only' option not set --- duration_ms: * ... + # Subtest: skipped subtest 4 ok 8 - skipped subtest 4 # SKIP --- duration_ms: * diff --git a/test/message/test_runner_output.out b/test/message/test_runner_output.out index 6c2fa7eb14cc72..e637ac9fb73cf8 100644 --- a/test/message/test_runner_output.out +++ b/test/message/test_runner_output.out @@ -1,12 +1,15 @@ TAP version 13 +# Subtest: sync pass todo ok 1 - sync pass todo # TODO --- duration_ms: * ... +# Subtest: sync pass todo with message ok 2 - sync pass todo with message # TODO this is a passing todo --- duration_ms: * ... +# Subtest: sync fail todo not ok 3 - sync fail todo # TODO --- duration_ms: * @@ -23,6 +26,7 @@ not ok 3 - sync fail todo # TODO * * ... +# Subtest: sync fail todo with message not ok 4 - sync fail todo with message # TODO this is a failing todo --- duration_ms: * @@ -41,19 +45,23 @@ not ok 4 - sync fail todo with message # TODO this is a failing todo * * ... +# Subtest: sync skip pass ok 5 - sync skip pass # SKIP --- duration_ms: * ... +# Subtest: sync skip pass with message ok 6 - sync skip pass with message # SKIP this is skipped --- duration_ms: * ... +# Subtest: sync pass ok 7 - sync pass --- duration_ms: * ... # this test should pass +# Subtest: sync throw fail not ok 8 - sync throw fail --- duration_ms: * @@ -70,14 +78,17 @@ not ok 8 - sync throw fail * * ... +# Subtest: async skip pass ok 9 - async skip pass # SKIP --- duration_ms: * ... +# Subtest: async pass ok 10 - async pass --- duration_ms: * ... +# Subtest: async throw fail not ok 11 - async throw fail --- duration_ms: * @@ -94,6 +105,7 @@ not ok 11 - async throw fail * * ... +# Subtest: async skip fail not ok 12 - async skip fail # SKIP --- duration_ms: * @@ -110,6 +122,7 @@ not ok 12 - async skip fail # SKIP * * ... +# Subtest: async assertion fail not ok 13 - async assertion fail --- duration_ms: * @@ -130,10 +143,12 @@ not ok 13 - async assertion fail * * ... +# Subtest: resolve pass ok 14 - resolve pass --- duration_ms: * ... +# Subtest: reject fail not ok 15 - reject fail --- duration_ms: * @@ -150,26 +165,33 @@ not ok 15 - reject fail * * ... +# Subtest: unhandled rejection - passes but warns ok 16 - unhandled rejection - passes but warns --- duration_ms: * ... +# Subtest: async unhandled rejection - passes but warns ok 17 - async unhandled rejection - passes but warns --- duration_ms: * ... +# Subtest: immediate throw - passes but warns ok 18 - immediate throw - passes but warns --- duration_ms: * ... +# Subtest: immediate reject - passes but warns ok 19 - immediate reject - passes but warns --- duration_ms: * ... +# Subtest: immediate resolve pass ok 20 - immediate resolve pass --- duration_ms: * ... +# Subtest: subtest sync throw fail + # Subtest: +sync throw fail not ok 1 - +sync throw fail --- duration_ms: * @@ -197,6 +219,7 @@ not ok 21 - subtest sync throw fail error: '1 subtest failed' code: 'ERR_TEST_FAILURE' ... +# Subtest: sync throw non-error fail not ok 22 - sync throw non-error fail --- duration_ms: * @@ -204,6 +227,11 @@ not ok 22 - sync throw non-error fail error: 'Symbol(thrown symbol from sync throw non-error fail)' code: 'ERR_TEST_FAILURE' ... +# Subtest: level 0a + # Subtest: level 1a + # Subtest: level 1b + # Subtest: level 1c + # Subtest: level 1d ok 1 - level 1a --- duration_ms: * @@ -225,6 +253,10 @@ ok 23 - level 0a --- duration_ms: * ... +# Subtest: top level + # Subtest: +long running + # Subtest: +short running + # Subtest: ++short running not ok 1 - +long running --- duration_ms: * @@ -249,18 +281,22 @@ not ok 24 - top level error: '1 subtest failed' code: 'ERR_TEST_FAILURE' ... +# Subtest: invalid subtest - pass but subtest fails ok 25 - invalid subtest - pass but subtest fails --- duration_ms: * ... +# Subtest: sync skip option ok 26 - sync skip option # SKIP --- duration_ms: * ... +# Subtest: sync skip option with message ok 27 - sync skip option with message # SKIP this is skipped --- duration_ms: * ... +# Subtest: sync skip option is false fail not ok 28 - sync skip option is false fail --- duration_ms: * @@ -276,59 +312,73 @@ not ok 28 - sync skip option is false fail * * ... +# Subtest: ok 29 - --- duration_ms: * ... +# Subtest: functionOnly ok 30 - functionOnly --- duration_ms: * ... +# Subtest: ok 31 - --- duration_ms: * ... +# Subtest: test with only a name provided ok 32 - test with only a name provided --- duration_ms: * ... +# Subtest: ok 33 - --- duration_ms: * ... +# Subtest: ok 34 - # SKIP --- duration_ms: * ... +# Subtest: test with a name and options provided ok 35 - test with a name and options provided # SKIP --- duration_ms: * ... +# Subtest: functionAndOptions ok 36 - functionAndOptions # SKIP --- duration_ms: * ... +# Subtest: escaped description \\ \# \\\#\\ ok 37 - escaped description \\ \# \\\#\\ --- duration_ms: * ... +# Subtest: escaped skip message ok 38 - escaped skip message # SKIP \#skip --- duration_ms: * ... +# Subtest: escaped todo message ok 39 - escaped todo message # TODO \#todo --- duration_ms: * ... +# Subtest: escaped diagnostic ok 40 - escaped diagnostic --- duration_ms: * ... # \#diagnostic +# Subtest: callback pass ok 41 - callback pass --- duration_ms: * ... +# Subtest: callback fail not ok 42 - callback fail --- duration_ms: * @@ -339,18 +389,22 @@ not ok 42 - callback fail * * ... +# Subtest: sync t is this in test ok 43 - sync t is this in test --- duration_ms: * ... +# Subtest: async t is this in test ok 44 - async t is this in test --- duration_ms: * ... +# Subtest: callback t is this in test ok 45 - callback t is this in test --- duration_ms: * ... +# Subtest: callback also returns a Promise not ok 46 - callback also returns a Promise --- duration_ms: * @@ -358,6 +412,7 @@ not ok 46 - callback also returns a Promise error: 'passed a callback but also returned a Promise' code: 'ERR_TEST_FAILURE' ... +# Subtest: callback throw not ok 47 - callback throw --- duration_ms: * @@ -373,6 +428,7 @@ not ok 47 - callback throw * * ... +# Subtest: callback called twice not ok 48 - callback called twice --- duration_ms: * @@ -383,10 +439,12 @@ not ok 48 - callback called twice * * ... +# Subtest: callback called twice in different ticks ok 49 - callback called twice in different ticks --- duration_ms: * ... +# Subtest: callback called twice in future tick not ok 50 - callback called twice in future tick --- duration_ms: * @@ -396,6 +454,19 @@ not ok 50 - callback called twice in future tick stack: |- * ... +# Subtest: callback async throw +# Subtest: callback async throw after done +# Subtest: only is set but not in only mode + # Subtest: running subtest 1 + # Subtest: running subtest 2 + # Subtest: running subtest 3 + # Subtest: running subtest 4 +# Subtest: custom inspect symbol fail +# Subtest: custom inspect symbol that throws fail +# Subtest: subtest sync throw fails + # Subtest: sync throw fails at first + # Subtest: sync throw fails at second +# Subtest: invalid subtest fail not ok 51 - callback async throw --- duration_ms: * diff --git a/test/message/test_runner_unresolved_promise.out b/test/message/test_runner_unresolved_promise.out index 98f52966c33bcb..58b3a4ed89a616 100644 --- a/test/message/test_runner_unresolved_promise.out +++ b/test/message/test_runner_unresolved_promise.out @@ -1,8 +1,10 @@ TAP version 13 +# Subtest: pass ok 1 - pass --- duration_ms: * ... +# Subtest: never resolving promise not ok 2 - never resolving promise --- duration_ms: * @@ -12,6 +14,7 @@ not ok 2 - never resolving promise stack: |- * ... +# Subtest: fail not ok 3 - fail --- duration_ms: *