From: David L. Jones Date: Mon, 13 May 2019 20:32:53 +0000 (+0000) Subject: [Support] Ensure redirected outputs don't contain output from previous tests. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d6664e77e701b6ba0a6c21a446dabd10ef36d3de;p=llvm [Support] Ensure redirected outputs don't contain output from previous tests. stdout may be buffered, and may not flush on every write. Explicitly flushing before redirecting the output ensures that the captured output does not contain output from other tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360617 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/unittests/Support/CommandLineTest.cpp b/unittests/Support/CommandLineTest.cpp index 2bf07e37494..4fb20b18d9b 100644 --- a/unittests/Support/CommandLineTest.cpp +++ b/unittests/Support/CommandLineTest.cpp @@ -1085,6 +1085,7 @@ public: // Return std::string because the output of a failing EXPECT check is // unreadable for StringRef. It also avoids any lifetime issues. template std::string runTest(Ts... OptionAttributes) { + outs().flush(); // flush any output from previous tests AutoDeleteFile File; { OutputRedirector Stdout(fileno(stdout));