diff --git a/test/main.cpp b/test/main.cpp index 4bfaa095f..adb62218e 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include int test_main(); @@ -43,8 +44,10 @@ int main() // on darwin, stdout is set to non-blocking mode by default // which sometimes causes tests to fail with EAGAIN just // by printing logs - int flags = fcntl(stdout, F_GETFL, 0); - fcntl(stdout, F_SETFL, flags & ~O_NONBLOCK); + int flags = fcntl(fileno(stdout), F_GETFL, 0); + fcntl(fileno(stdout), F_SETFL, flags & ~O_NONBLOCK); + flags = fcntl(fileno(stderr), F_GETFL, 0); + fcntl(fileno(stderr), F_SETFL, flags & ~O_NONBLOCK); #endif #ifndef BOOST_NO_EXCEPTIONS @@ -52,19 +55,21 @@ int main() { #endif test_main(); - return tests_failure ? 1 : 0; #ifndef BOOST_NO_EXCEPTIONS } catch (std::exception const& e) { std::cerr << "Terminated with exception: \"" << e.what() << "\"\n"; - return 1; + tests_failure = true; } catch (...) { std::cerr << "Terminated with unknown exception\n"; - return 1; + tests_failure = true; } #endif + fflush(stdout); + fflush(stderr); + return tests_failure ? 1 : 0; }