-
Notifications
You must be signed in to change notification settings - Fork 277
Don't run failed unit tests by default #5248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
000a799
to
a665490
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don’t want to run [!shouldfail]
test you can just provide ~[!shouldfail]
as a tag filter.
unit/testing-utils/use_catch.h
Outdated
@@ -36,4 +36,7 @@ Author: Michael Tautschnig | |||
#include <util/pragma_pop.def> | |||
#endif | |||
|
|||
/// Add to the end of test tags to mark a test that is expected to fail | |||
#define XFAIL "[.][shouldfail]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the commit message:
These tests won't be run by default (de-cluttering the output with expected failures). When run, they will fail if they pass
In previous PR Owen / Micahel complained that shouldfail was misleading. They shouldn't fail, in the perfect world, but they do due to known bug. We felt expected fail (or XFAIL as python calls them) was clearer. Can change to EXPECTED_FAIL
if you'd prefer?
@@ -12,7 +12,7 @@ Author: Diffblue Limited. | |||
|
|||
SCENARIO( | |||
"Lazy load lambda methods", | |||
"[core][java_bytecode][ci_lazy_methods][lambdas][!mayfail]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mayfail
doesn’t stop a test from running, it just means test failure isn’t counted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A test that can pass or fail is bad - since no body will observe if it changes state. I believe this has been erroneously marked as mayfail, since it passes.
@@ -188,7 +188,7 @@ void validate_local_variable_lambda_assignment( | |||
SCENARIO( | |||
"Converting invokedynamic with a local lambda", | |||
"[core]" | |||
"[lambdas][java_bytecode][java_bytecode_convert_method][!mayfail]") | |||
"[lambdas][java_bytecode][java_bytecode_convert_method]" XFAIL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be [!shouldfail]
(it’s shouldfail
in the macro), and I still dont think this should be a macro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in later commit
.travis.yml
Outdated
- env UBSAN_OPTIONS=print_stacktrace=1 make -C jbmc/regression test-parallel "CXX=${COMPILER} ${EXTRA_CXXFLAGS}" -j2 JOBS=2 | ||
- make -C jbmc/unit "CXX=${COMPILER} ${EXTRA_CXXFLAGS}" -j2 | ||
- make -C jbmc/unit test | ||
- echo "Running expected failure tests" | ||
- make TAGS="[shouldfail]" -C jbmc/unit test xfail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??? Why not just use the builtin !shouldfail
mechanism?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean? The trailing xfail
was a typo, but this is me passing the appropriate tags to the unit runner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be [!shouldfail]
, not [shouldfail]
. I believe might be fixed by a later commit?
jbmc/unit/Makefile
Outdated
if ! ./$(CATCH_TEST) -l | grep -q "^$(N_CATCH_TESTS) test cases" ; then \ | ||
./$(CATCH_TEST) -l ; fi | ||
./$(CATCH_TEST) | ||
if ! ./$(CATCH_TEST) *,[.] -l | grep -q "^$(N_CATCH_TESTS) matching test cases" ; then \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not sure what this supposed to mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is listing all tests, even hidden tests, to check the number of tests == the number of tests in source. (The check is to catch people forgetting to add their unit tests to Makefile
).
This is also an option. I prefer my approach as it makes it easier to use for the general case. I.e. to run the unit tests, you just run the unit tests binary. You neither need to provide additional flags, nor do you get misleading output about failed tests. Happy to change to that though, if that is preferred. |
@@ -355,9 +355,13 @@ script: | |||
- env PATH=$PATH:`pwd`/src/solvers UBSAN_OPTIONS=print_stacktrace=1 make -C regression/cbmc test-cprover-smt2 | |||
- make -C unit "CXX=${COMPILER} ${EXTRA_CXXFLAGS}" -j2 | |||
- make -C unit test | |||
- echo "Running expected failure tests" | |||
- make TAGS="[!shouldfail]" -C unit test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about CMake configurations? Does anything need to be done for those?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot, fixed
b1df747
to
5d92f1b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for checking/fixing the cmake stuff.
jbmc/unit/Makefile
Outdated
if ! ./$(CATCH_TEST) -l | grep -q "^$(N_CATCH_TESTS) test cases" ; then \ | ||
./$(CATCH_TEST) -l ; fi | ||
./$(CATCH_TEST) | ||
if ! ./$(CATCH_TEST) *,[.] -l | grep -q "^$(N_CATCH_TESTS) matching test cases" ; then \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hannes-steffenhagen-diffblue how about?
if ! ./$(CATCH_TEST) *,[.] -l | grep -q "^$(N_CATCH_TESTS) matching test cases" ; then \ | |
# Include hidden tests by specifying "*,[.]" for tests to count | |
if ! ./$(CATCH_TEST) *,[.] -l | grep -q "^$(N_CATCH_TESTS) matching test cases" ; then \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. Ok, I thought this was using a glob pattern somehow. Would you mind putting quotes around it to clarify it’s supposed to be passed as an argument to catch as-is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done - will merge on green CI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don’t really like using a macro for this, but otherwise LGTM now.
These tests won't be run by default (de-cluttering the output with expected failures). When run, they will fail if they pass
These don't fail, so no reason not to have them running
This ensures that failed tests don't get inadvertently fixed, without cluttering the normal output
5d92f1b
to
92dac11
Compare
92dac11
to
6176871
Compare
This replaces #2256. By using the tag
[.]
, the tests are not run by default, leading to no useless output when another unit test fails. By changing[!mayfail]
to[!shouldfail
] means that these tests fail if they pass. This stops tests inadvertently getting fixed without anyone noticing. I used @owen-mc-diffblue suggestion ofxfail
for an expected failure. Finally, I added a separate run of these failed tests to CI.