Skip to content

Commit 0b58549

Browse files
committed
B Update Boost.ut, to fix exit status if any Approval Tests failed.
Now using boost-ext/ut@dde2cba This fixes #87. Docs and release notes updated.
1 parent 91c9c52 commit 0b58549

File tree

4 files changed

+35
-28
lines changed

4 files changed

+35
-28
lines changed

build/relnotes_x.y.z.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
* **New features**
66
* None
77
* **Bug fixes**
8-
* None
8+
* Boost.UT tests now correctly return non-zero exit status if any Approval Tests failed. (#87)
99
* **Other changes**
10-
* Update to Boost.UT [commit 46a4f2e3f41212dd6db2a77bf7c3795cf461b55e](https://github.com/boost-experimental/ut/commit/46a4f2e3f41212dd6db2a77bf7c3795cf461b55e)
10+
* Update to Boost.UT [commit dde2cba5123444faa82e5c17fcd99f68fe991d89](https://github.com/boost-experimental/ut/commit/dde2cba5123444faa82e5c17fcd99f68fe991d89)

doc/UsingUT.md

-8
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,12 @@ To change this file edit the source file and then execute ./run_markdown_templat
1414
## Contents
1515

1616
* [Getting Started With \[Boost\].UT](#getting-started-with-boostut)
17-
* [Important Note: Issue 87](#important-note-issue-87)
1817
* [Requirements](#requirements)
1918
* [Usage examples](#usage-examples)<!-- endtoc -->
2019

2120

2221
## Getting Started With \[Boost\].UT
2322

24-
### Important Note: Issue 87
25-
26-
* As of 2020-01-15, there is a known serious issue with using this test framework with Approval Tests, in that **the test framework does not currently report any Approval Test test failures via the exit status of the test program**.
27-
* This means that any CI builds or ctest runs will look like they succeeded, whereas they may in fact not have done.
28-
* For details and progress, please see [issue 87: Boost.UT tests spuriously pass, by returning 0 exit status even after failure](https://github.com/approvals/ApprovalTests.cpp/issues/87).
29-
---
30-
3123
The [\[Boost\].UT](https://github.com/boost-experimental/ut) test framework works well with Approval Tests.
3224

3325
\[Boost\].UT is a single header/single module, macro-free μ(micro)/Unit Testing Framework that requires C++17 / C++20

doc/mdsource/UsingUT.source.md

-7
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ toc
88

99
## Getting Started With \[Boost\].UT
1010

11-
### Important Note: Issue 87
12-
13-
* As of 2020-01-15, there is a known serious issue with using this test framework with Approval Tests, in that **the test framework does not currently report any Approval Test test failures via the exit status of the test program**.
14-
* This means that any CI builds or ctest runs will look like they succeeded, whereas they may in fact not have done.
15-
* For details and progress, please see [issue 87: Boost.UT tests spuriously pass, by returning 0 exit status even after failure](https://github.com/approvals/ApprovalTests.cpp/issues/87).
16-
---
17-
1811
The [\[Boost\].UT](https://github.com/boost-experimental/ut) test framework works well with Approval Tests.
1912

2013
\[Boost\].UT is a single header/single module, macro-free μ(micro)/Unit Testing Framework that requires C++17 / C++20

third_party/ut/include/boost/ut.hpp

+33-11
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// (See accompanying file LICENSE_1_0.txt or copy at
66
// http://www.boost.org/LICENSE_1_0.txt)
77
//
8-
//git version: 46a4f2e3f41212dd6db2a77bf7c3795cf461b55e
8+
//git version: dde2cba5123444faa82e5c17fcd99f68fe991d89
99
#if defined(__cpp_modules)
1010
export module boost.ut;
1111
export import std;
@@ -1145,7 +1145,6 @@ class reporter {
11451145
auto on(events::test_begin test_begin) -> void {
11461146
printer_ << "Running \"" << test_begin.name << "\"...";
11471147
fails_ = asserts_.fail;
1148-
exception_ = false;
11491148
}
11501149

11511150
auto on(events::test_run test_run) -> void {
@@ -1158,7 +1157,7 @@ class reporter {
11581157
}
11591158

11601159
auto on(events::test_end) -> void {
1161-
if (asserts_.fail > fails_ or exception_) {
1160+
if (asserts_.fail > fails_) {
11621161
++tests_.fail;
11631162
printer_ << '\n'
11641163
<< printer_.colors().fail << "FAILED" << printer_.colors().none
@@ -1176,11 +1175,10 @@ class reporter {
11761175
}
11771176

11781177
auto on(events::exception exception) -> void {
1179-
exception_ = true;
11801178
printer_ << "\n " << printer_.colors().fail
11811179
<< "Unexpected exception with message:\n"
11821180
<< exception.what() << printer_.colors().none;
1183-
++tests_.except;
1181+
++asserts_.fail;
11841182
}
11851183

11861184
template <class TExpr>
@@ -1239,7 +1237,6 @@ class reporter {
12391237
std::size_t pass{};
12401238
std::size_t fail{};
12411239
std::size_t skip{};
1242-
std::size_t except{};
12431240
} tests_{};
12441241

12451242
struct {
@@ -1248,7 +1245,6 @@ class reporter {
12481245
} asserts_{};
12491246

12501247
std::size_t fails_{};
1251-
bool exception_{};
12521248

12531249
TPrinter printer_{};
12541250
};
@@ -1338,19 +1334,18 @@ class runner {
13381334
std::cout << '\n';
13391335
}
13401336

1341-
active_exception_ = false;
13421337
#if defined(__cpp_exceptions)
13431338
try {
13441339
#endif
13451340
test();
13461341
#if defined(__cpp_exceptions)
13471342
} catch (const events::fatal_assertion&) {
13481343
} catch (const std::exception& e) {
1344+
++fails_;
13491345
reporter_.on(events::exception{e.what()});
1350-
active_exception_ = true;
13511346
} catch (...) {
1347+
++fails_;
13521348
reporter_.on(events::exception{"Unknown exception"});
1353-
active_exception_ = true;
13541349
}
13551350
#endif
13561351

@@ -1447,7 +1442,6 @@ class runner {
14471442
std::vector<void (*)()> suites_{};
14481443
std::size_t level_{};
14491444
bool run_{};
1450-
bool active_exception_{};
14511445
std::size_t fails_{};
14521446
std::array<std::string_view, MaxPathSize> path_{};
14531447
filter filter_{};
@@ -1468,6 +1462,20 @@ extern void on(events::test<utility::function<void()>>);
14681462
extern void on(events::skip<>);
14691463
[[nodiscard]] extern auto on(events::assertion<events::expr>) -> bool;
14701464
extern void on(events::fatal_assertion);
1465+
extern void on(events::log<bool>);
1466+
extern void on(events::log<char>);
1467+
extern void on(events::log<short>);
1468+
extern void on(events::log<int>);
1469+
extern void on(events::log<long>);
1470+
extern void on(events::log<long long>);
1471+
extern void on(events::log<unsigned>);
1472+
extern void on(events::log<unsigned char>);
1473+
extern void on(events::log<unsigned short>);
1474+
extern void on(events::log<unsigned long>);
1475+
extern void on(events::log<float>);
1476+
extern void on(events::log<double>);
1477+
extern void on(events::log<long double>);
1478+
extern void on(events::log<const char*>);
14711479
extern void on(events::log<utility::string_view>);
14721480
#endif
14731481

@@ -1482,6 +1490,20 @@ void on(events::skip<> skip) { cfg<override>.on(skip); }
14821490
return cfg<override>.on(static_cast<decltype(assertion)&&>(assertion));
14831491
}
14841492
void on(events::fatal_assertion assertion) { cfg<override>.on(assertion); }
1493+
void on(events::log<bool> l) { cfg<override>.on(l); }
1494+
void on(events::log<char> l) { cfg<override>.on(l); }
1495+
void on(events::log<short> l) { cfg<override>.on(l); }
1496+
void on(events::log<int> l) { cfg<override>.on(l); }
1497+
void on(events::log<long> l) { cfg<override>.on(l); }
1498+
void on(events::log<long long> l) { cfg<override>.on(l); }
1499+
void on(events::log<unsigned> l) { cfg<override>.on(l); }
1500+
void on(events::log<unsigned char> l) { cfg<override>.on(l); }
1501+
void on(events::log<unsigned short> l) { cfg<override>.on(l); }
1502+
void on(events::log<unsigned long> l) { cfg<override>.on(l); }
1503+
void on(events::log<float> l) { cfg<override>.on(l); }
1504+
void on(events::log<double> l) { cfg<override>.on(l); }
1505+
void on(events::log<long double> l) { cfg<override>.on(l); }
1506+
void on(events::log<const char*> l) { cfg<override>.on(l); }
14851507
void on(events::log<utility::string_view> l) { cfg<override>.on(l); }
14861508
#endif
14871509
} // namespace link

0 commit comments

Comments
 (0)