Closed claremacrae closed 4 years ago
@kris-jusiak Hello, please could you advise on how to track this down? It's means that all our uses of Boost.ut spuriously pass in test, which is rather worrying.
It occurred with 20bf64b6f6a8b9bd1e87de243460b26b837ded55 in this project, which contains 8004290d195b08eda531eb015ddcda2e11d41ce9 of Boost.UT.
The source code of the test in this version is: https://github.com/approvals/ApprovalTests.cpp/blob/20bf64b6f6a8b9bd1e87de243460b26b837ded55/tests/UT_Tests/ApprovalTestTests.cpp
I thought maybe it would detect a failure on the last test case, so I changed the content of the file tests/UT_Tests/approval_tests/ApprovalTestTests.YouCanSpecifyYourFileExtensionWithFormatter.approved.md
but the exit code was still 0.
@kris-jusiak 💡 I think I understand the problem. In the above two commits, I added some tests that use expect()
to report any issues. And if they fail, the exit status is 255.
Approval Tests report failures by throwing exceptions, which they then assume will result in a non-zero exit status. It looks to me like if the only errors are unexpected exceptions, this doesn't get reported in Boost.UT's exit status....
Is this enough information? Thanks in advance for any help that you can offer...
This problem matters when I run Boost.UT v1.1.6 on Mac... It looks like all ApprovalTests Boost.UT verifications pass, when running the tests with ctest .
, as the exit status is 0, and no messages are written out.
If ctest is run with --verbose
then there is console output that indicates the failure to get the filename.
--output-on-error
doesn't help, if the only failing tests are exceptions, as thrown by ApprovalTests - because the test exits with 0 (success) and so ctest thinks that everyone was all good.
I think this may have slightly contributed to the challenges understanding the Ninja problems in #74:
Various combinations of Boost.ut version, compilers, and running either via ctest or directly, resulted in some confusion.
@jwillikers and @lp55 please note:
ctest --verbose
for now. @claremacrae Noted. Thank you for the update Clare!
I’ve got a fix for this. I’ll submit a PR to Boost.UT later this week.
When I hack the approval files in
tests/UT_Tests/ApprovalTestTests.cpp
to make the test fail, and then run the test via this:I expect to see test saying the test failed.
However, it gives
then Test reports the tests pass, even though a diff tool popped up to say an error occurred.
then I do see the console output, but the test still reports it passes.
I presume that this is because Boost.UT is returning a 0 exit status even after an error has occurred.
This is most serious in the case where the user's build is not set up correctly to work with Approval Tests, e.g. when using Ninja with an in-source build...
Approval Tests will throw one exception per test case, which 'ctest .' will swallow - and then ctest will report that all the tests succeeded. When in fact they all failed...