summaryrefslogtreecommitdiff
path: root/tests/util/server/src
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2024-02-28 15:12:21 -0700
committerGitHub <noreply@github.com>2024-02-28 22:12:21 +0000
commitb6e44f91ad55f9737d65a4832d10cfa608f27c41 (patch)
treee184d9c7b0a4ebbb7cbb20ab72cc99c07eb46da0 /tests/util/server/src
parentc9b2139b1e7e1240db792173118b7d54d16c5f73 (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/util/server/src')
-rw-r--r--tests/util/server/src/macros.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/util/server/src/macros.rs b/tests/util/server/src/macros.rs
index 530d8cea0..542214d20 100644
--- a/tests/util/server/src/macros.rs
+++ b/tests/util/server/src/macros.rs
@@ -30,7 +30,9 @@ macro_rules! timeout {
let timeout = *timeout.get(0).unwrap_or(&300);
::std::thread::spawn(move || {
if rx.recv_timeout(::std::time::Duration::from_secs(timeout)) == Err(::std::sync::mpsc::RecvTimeoutError::Timeout) {
+ use std::io::Write;
eprintln!("Test {function} timed out after {timeout} seconds, aborting");
+ _ = std::io::stderr().flush();
::std::process::exit(1);
}
});