From b6e44f91ad55f9737d65a4832d10cfa608f27c41 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Wed, 28 Feb 2024 15:12:21 -0700 Subject: 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 ----- ``` --- tests/testdata/run/websocket_server_idletimeout.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tests/testdata/run/websocket_server_idletimeout.ts') diff --git a/tests/testdata/run/websocket_server_idletimeout.ts b/tests/testdata/run/websocket_server_idletimeout.ts index 85b031b8e..82a35605a 100644 --- a/tests/testdata/run/websocket_server_idletimeout.ts +++ b/tests/testdata/run/websocket_server_idletimeout.ts @@ -11,10 +11,12 @@ const { response, socket } = Deno.upgradeWebSocket(request, { idleTimeout: 1, }); socket.onerror = (e) => { + console.log(e); assertEquals((e as ErrorEvent).message, "No response from ping frame."); errorDeferred.resolve(); }; socket.onclose = (e) => { + console.log(e); assertEquals(e.reason, "No response from ping frame."); closeDeferred.resolve(); }; @@ -22,4 +24,6 @@ await respondWith(response); await errorDeferred.promise; await closeDeferred.promise; -listener.close(); + +// TODO(mmastrac): this doesn't exit on its own. Why? +Deno.exit(123); -- cgit v1.2.3