From 76c3538315e5402ab0cd15877f4b980c6a074908 Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Tue, 4 Sep 2018 20:28:30 -0400 Subject: [PATCH] Suppress MSVC error dialogs and add test for report_errors() --- include/boost/core/lightweight_test.hpp | 8 ++++++-- test/Jamfile.v2 | 1 + test/lightweight_test_fail11.cpp | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 test/lightweight_test_fail11.cpp diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index e90ba56..b6ca7b3 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -46,11 +46,15 @@ class test_result { public: test_result() : report_(false) - , errors_(0) { } + , errors_(0) { +#ifdef BOOST_MSVC + ::_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); +#endif + } ~test_result() { if (!report_) { - BOOST_LIGHTWEIGHT_TEST_OSTREAM << "report_errors() not called" << std::endl; + BOOST_LIGHTWEIGHT_TEST_OSTREAM << "main() should return report_errors()" << std::endl; std::abort(); } } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 284b4c1..c714d56 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -89,6 +89,7 @@ run-fail lightweight_test_fail8.cpp ; run-fail lightweight_test_fail8.cpp : : : off : lightweight_test_fail8_no_rtti ; run-fail lightweight_test_fail9.cpp ; run-fail lightweight_test_fail10.cpp ; +run-fail lightweight_test_fail11.cpp ; run-fail lightweight_test_lt_fail.cpp ; run-fail lightweight_test_le_fail.cpp ; run-fail lightweight_test_gt_fail.cpp ; diff --git a/test/lightweight_test_fail11.cpp b/test/lightweight_test_fail11.cpp new file mode 100644 index 0000000..591813a --- /dev/null +++ b/test/lightweight_test_fail11.cpp @@ -0,0 +1,14 @@ +/* +Copyright 2018 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include + +int main() +{ + BOOST_TEST(true); + return 0; +}