Skip to content

Commit 15168d3

Browse files
authored
stop spraying numbers to stdout during test runs (#892)
1 parent 8061338 commit 15168d3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

nexus/tests/integration_tests/unauthorized.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,20 @@ fn record_operation(whichtest: WhichTest<'_>) {
482482
// codes.
483483
let t = term::stdout();
484484
if let Some(mut term) = t {
485+
// We just want to write one green character to stdout. But we also
486+
// want it to be captured by the test runner like people usually expect
487+
// when they haven't passed "--nocapture". The test runner only
488+
// captures output from the `print!` family of macros, not all writes to
489+
// stdout. So we write the formatting control character, flush that (to
490+
// make sure it gets emitted before our character), use print for our
491+
// character, reset the terminal, then flush that.
492+
//
493+
// Note that this likely still writes the color-changing control
494+
// characters to the real stdout, even without "--nocapture". That
495+
// sucks, but at least you don't see them.
485496
term.fg(term::color::GREEN).unwrap();
486-
write!(term, "{}", c).unwrap();
497+
term.flush().unwrap();
498+
print!("{}", c);
487499
term.reset().unwrap();
488500
term.flush().unwrap();
489501
} else {

0 commit comments

Comments
 (0)