Skip to content

Commit 628ea0b

Browse files
committed
Properly detect fatal errors in Boost.Test
1 parent aad8926 commit 628ea0b

5 files changed

Lines changed: 37 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 0.4.5
2+
3+
- Properly handle fatal errors in Boost.Test.
4+
Thanks @dplucenio for the report.
5+
6+
17
# 0.4.4
28

39
- Properly handle fixture failures in Boost.Test.

pytest_cpp/boost.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def _parse_log(self, log):
102102
log_root = ElementTree.fromstring(log)
103103
parsed_elements.extend(log_root.findall('Exception'))
104104
parsed_elements.extend(log_root.findall('Error'))
105+
parsed_elements.extend(log_root.findall('FatalError'))
105106

106107
result = []
107108
for elem in parsed_elements:

tests/SConstruct

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ Export('env genv')
2020

2121
genv.Program('gtest.cpp')
2222

23-
for filename in ('boost_success.cpp', 'boost_failure.cpp', 'boost_error.cpp', 'boost_fixture_setup_error.cpp'):
23+
boost_files = [
24+
'boost_success.cpp',
25+
'boost_failure.cpp',
26+
'boost_fatal_error.cpp',
27+
'boost_error.cpp',
28+
'boost_fixture_setup_error.cpp',
29+
]
30+
31+
for filename in boost_files:
2432
env.Program(filename)
2533

2634
SConscript('acceptance/googletest-samples/SConscript')

tests/boost_fatal_error.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <stdexcept>
2+
#define BOOST_TEST_MODULE MyTest
3+
#include <boost/test/included/unit_test.hpp>
4+
5+
6+
BOOST_AUTO_TEST_CASE( test_failure_1 )
7+
{
8+
BOOST_REQUIRE( 2 * 3 == 5 );
9+
}
10+

tests/test_pytest_cpp.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ def test_boost_failure(exes):
119119
assert fail2.get_file_reference() == ("boost_failure.cpp", 14)
120120

121121

122+
def test_boost_fatal_error(exes):
123+
facade = BoostTestFacade()
124+
failures = facade.run_test(exes.get('boost_fatal_error'), '<unused>')
125+
assert len(failures) == 1
126+
127+
fail1, = failures
128+
colors = ('red', 'bold')
129+
assert fail1.get_lines() == [('critical check 2 * 3 == 5 failed', colors)]
130+
assert fail1.get_file_reference() == ("boost_fatal_error.cpp", 8)
131+
132+
122133
def test_boost_error(exes):
123134
facade = BoostTestFacade()
124135
failures = facade.run_test(exes.get('boost_error'), '<unused>')

0 commit comments

Comments
 (0)