diff options
author | Matt Mastracci <matthew@mastracci.com> | 2024-02-28 15:12:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-28 22:12:21 +0000 |
commit | b6e44f91ad55f9737d65a4832d10cfa608f27c41 (patch) | |
tree | e184d9c7b0a4ebbb7cbb20ab72cc99c07eb46da0 /tests/testdata/test | |
parent | c9b2139b1e7e1240db792173118b7d54d16c5f73 (diff) |
fix(cli): ensure that pre- and post-test output is flushed at the appropriate times (#22611)
Some `deno_std` tests were failing to print output that was resolved
after the last test finished. In addition, output printed before tests
began would sometimes appear above the "running X tests ..." line, and
sometimes below it depending on timing.
We now guarantee that all output is flushed before and after tests run,
making the output consistent.
Pre-test and post-test output are captured in `------ pre-test output
------` and `------ post-test output ------` blocks to differentiate
them from the regular output blocks.
Here's an example of a test (that is much noisier than normal, but an
example of what the output will look like):
```
Check ./load_unload.ts
------- pre-test output -------
load
----- output end -----
running 1 test from ./load_unload.ts
test ...
------- output -------
test
----- output end -----
test ... ok ([WILDCARD])
------- post-test output -------
unload
----- output end -----
```
Diffstat (limited to 'tests/testdata/test')
-rw-r--r-- | tests/testdata/test/load_unload.out | 14 | ||||
-rw-r--r-- | tests/testdata/test/load_unload.ts | 3 |
2 files changed, 15 insertions, 2 deletions
diff --git a/tests/testdata/test/load_unload.out b/tests/testdata/test/load_unload.out index aef7531af..75187fa7b 100644 --- a/tests/testdata/test/load_unload.out +++ b/tests/testdata/test/load_unload.out @@ -1,6 +1,16 @@ -Check [WILDCARD]/test/load_unload.ts -running 1 test from ./test/load_unload.ts +Check [WILDCARD]/load_unload.ts +------- pre-test output ------- +load +----- pre-test output end ----- +running 1 test from [WILDCARD]/load_unload.ts +test ... +------- output ------- +test +----- output end ----- test ... ok ([WILDCARD]) +------- post-test output ------- +unload +----- post-test output end ----- ok | 1 passed | 0 failed ([WILDCARD]) diff --git a/tests/testdata/test/load_unload.ts b/tests/testdata/test/load_unload.ts index 2bd04a676..5027b949a 100644 --- a/tests/testdata/test/load_unload.ts +++ b/tests/testdata/test/load_unload.ts @@ -4,6 +4,7 @@ addEventListener("load", () => { throw new Error("Interval is already set"); } + console.log("load"); interval = setInterval(() => {}, 0); }); @@ -12,10 +13,12 @@ addEventListener("unload", () => { throw new Error("Interval was not set"); } + console.log("unload"); clearInterval(interval); }); Deno.test("test", () => { + console.log("test"); if (!interval) { throw new Error("Interval was not set"); } |