From c9168cca72105297a5d66dee0beb0bb192cb01ad Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Thu, 26 Feb 2015 15:31:24 +0100 Subject: [PATCH] libtest: flush output after every write Useful for debugging tests that hang forever. --- src/libtest/lib.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 82c1a4b1195..7c7f1fd478a 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -506,16 +506,25 @@ pub fn write_pretty(&mut self, if self.use_color { try!(term.reset()); } - Ok(()) + term.flush() + } + Raw(ref mut stdout) => { + try!(stdout.write_all(word.as_bytes())); + stdout.flush() } - Raw(ref mut stdout) => stdout.write_all(word.as_bytes()) } } pub fn write_plain(&mut self, s: &str) -> old_io::IoResult<()> { match self.out { - Pretty(ref mut term) => term.write_all(s.as_bytes()), - Raw(ref mut stdout) => stdout.write_all(s.as_bytes()) + Pretty(ref mut term) => { + try!(term.write_all(s.as_bytes())); + term.flush() + }, + Raw(ref mut stdout) => { + try!(stdout.write_all(s.as_bytes())); + stdout.flush() + }, } } -- GitLab