Skip to content

Commit 191250b

Browse files
committed
Fix close_output test.
1 parent 964a16a commit 191250b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tests/testsuite/build.rs

Lines changed: 14 additions & 3 deletions
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)