Skip to content

Commit 1653f35

Browse files
committed
Auto merge of #8587 - ehuss:close_output-fix, r=alexcrichton
Fix close_output test. The close_output test was randomly failing on rust-lang/rust's CI. This should fix the error. I ran the test in a loop on the rust-lang 16-thread CPU for 10,000 times over the course of 1.5 hours without fail. The same stress test without this patch failed relatively easily. I'm a bit on the fence, as this means the test is no longer testing a realistic scenario (the compiler usually doesn't emit a megabyte of diagnostics). Moving this test to a single-threaded runner should also solve the problem. I can't decide if it matters enough to bother. WDYT? Closes #8564
2 parents 964a16a + 191250b commit 1653f35

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tests/testsuite/build.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -4975,11 +4975,22 @@ fn close_output() {
49754975
let mut buf = [0];
49764976
drop(socket.read_exact(&mut buf));
49774977
let use_stderr = std::env::var("__CARGO_REPRO_STDERR").is_ok();
4978-
for i in 0..10000 {
4978+
// Emit at least 1MB of data.
4979+
// Linux pipes can buffer up to 64KB.
4980+
// This test seems to be sensitive to having other threads
4981+
// calling fork. My hypothesis is that the stdout/stderr
4982+
// file descriptors are duplicated into the child process,
4983+
// and during the short window between fork and exec, the
4984+
// file descriptor is kept alive long enough for the
4985+
// build to finish. It's a half-baked theory, but this
4986+
// seems to prevent the spurious errors in CI.
4987+
// An alternative solution is to run this test in
4988+
// a single-threaded environment.
4989+
for i in 0..100000 {
49794990
if use_stderr {
4980-
eprintln!("{}", i);
4991+
eprintln!("0123456789{}", i);
49814992
} else {
4982-
println!("{}", i);
4993+
println!("0123456789{}", i);
49834994
}
49844995
}
49854996
TokenStream::new()

0 commit comments

Comments
 (0)