Skip to content
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

Improve reporting of unmatched filters #1684

Merged
merged 14 commits into from
Aug 6, 2019
Merged

Conversation

sfranzen
Copy link
Contributor

@sfranzen sfranzen commented Jul 9, 2019

Description

This PR is for two issues related to filtering tests, reported in issue #1449.

It modifies various existing structures to allow checking whether any filters passed to a test executable did not result in any matching test cases, giving the user better feedback about the input. It also adds small helper classes to aid readability of the code. Additionally, the option -w NoTests is now correctly checked and an exit code 2 returned if there were any unmatched filters.

GitHub Issues

Fixes #1449. Also fixes #1683.

sfranzen added 4 commits July 7, 2019 21:43
This bug/feature request was reported in issue catchorg#1449. The new behaviour
is to collect a list of matches per filter, and call the reporter's
noMatchingTestCases if a filter has zero matches. Also, a non-zero exit
code (2) is now returned if the option "-w NoTests" is active.
It has been renamed from TestSet to be more similar to the naming used
by the Context class.
@codecov
Copy link

codecov bot commented Jul 10, 2019

Codecov Report

Merging #1684 into master will increase coverage by 0.26%.
The diff coverage is 91.76%.

@@            Coverage Diff             @@
##           master    #1684      +/-   ##
==========================================
+ Coverage   86.18%   86.44%   +0.26%     
==========================================
  Files         136      136              
  Lines        5180     5266      +86     
==========================================
+ Hits         4464     4552      +88     
+ Misses        716      714       -2

@sfranzen
Copy link
Contributor Author

The remaining failure is with the AppVeyor coverage build and is caused by OpenCppCoverage marking the exit code as an error where CTest does not (because it has WILL_FAIL TRUE). Is there an elegant way to ignore the exit code in this specific case?

@horenmar
Copy link
Member

I'll investigate the problem -- it is my understanding that both OpenCppCoverage and the wrapper we use for CTest should just pass-through the return codes back to CTest, so it should not fail.

@horenmar
Copy link
Member

After closer look, the helper executable does not actually pass the return code up the stack... I'll try to fix it tomorrow.

@sfranzen
Copy link
Contributor Author

In the meantime I've downloaded this coverage tool and played with it, and I could also obtain a coverage report for all tests by running OpenCppCoverage [coverage options] -- ctest [ctest options]. CTest then hosts the individual test commands and completes with return code 0 as long as all test cases return 0 or else have WILL_FAIL TRUE. This seems a lot simpler than the current setup, though I haven't studied it in full detail -- would it be significantly different?

@horenmar
Copy link
Member

Hmmm, I'll take a look -- it has honestly never occurred to me to run coverage over the top level ctest process and let it take coverage from the children processes...

@sfranzen
Copy link
Contributor Author

I found it via this issue while googling about OpenCppCoverage. Oddly enough its documentation does not mention CMake or CTest at all, only the export + merge method that is currently used by Catch2.

@horenmar
Copy link
Member

Good news: I fixed the helper to pass through return codes, and will merge it in the evening.

Bad news: I also found out that the coverage merging fails in a way I am unable to reproduce locally, and will have to poke the CI to fix (second one this week, ugh)

What this means is that you should rebase the PR tomorrow/late evening today and I'll start reviewing the changes.


I'll also open up an issue to investigate the different method of gathering coverage.

horenmar added a commit that referenced this pull request Jul 20, 2019
projects/CMakeLists.txt Outdated Show resolved Hide resolved
sfranzen and others added 2 commits July 23, 2019 21:04
Co-Authored-By: Martin Hořeňovský <martin.horenovsky@gmail.com>
projects/CMakeLists.txt Outdated Show resolved Hide resolved
@horenmar
Copy link
Member

You will probably need to pass through the path to the test binary from the main script.

@sfranzen
Copy link
Contributor Author

I think you were right, here's to hoping this is the final change!

@horenmar
Copy link
Member

horenmar commented Aug 1, 2019

There is 1 more thing that needs fixing and one that I am not quite sure about.

Needs fixing: the filter string in No test cases matched 'asdafs' should roundtrip, so that it can be again used as a filter provided to Catch. Currently it does not:

$  ./projects/SelfTest [asdafs]
Filters: [asdafs]
No test cases matched 'asdafs'
===============================================================================
No tests ran

The part I am not sure about is whether the extended reporting should be provided even if the -w NoTests flag was not specified.

@sfranzen
Copy link
Contributor Author

sfranzen commented Aug 4, 2019

This was slightly trickier as I've now had to mess with the test spec parser, but it does the trick and passes the tests on my machine. About the reporting, I would prefer to always leave at least a textual trace, so the user can see where they mistyped or misconfigured test cases.

@horenmar
Copy link
Member

horenmar commented Aug 5, 2019

Okay, this looks good now.

Would you prefer if I squash-merge it, or if you rebase and cleanup the branch?

@sfranzen
Copy link
Contributor Author

sfranzen commented Aug 6, 2019

I'm fine with squashing, it is just improvements/fixes and regression tests that don't warrant multiple commits IMO. Thanks for the careful review!

@horenmar horenmar merged commit 6070745 into catchorg:master Aug 6, 2019
@sfranzen sfranzen deleted the fix-#1449 branch August 7, 2019 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants