-
Notifications
You must be signed in to change notification settings - Fork 283
GCovr generates no coverage data for CMake out of source builds #230
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 o 8000 ur terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thank you for this detailed and useful report, I'll try to look into it more deeply over the weekend. Are you using gcovr 3.4? If not, does anything change when you update? This might probably be a Windows issue, not an out-of-source issue. The log shows some filenames as |
Thanks for the reply @latk , I can confirm that I'm using 3.4. For a test, I threw up a tiny little test project that simply contains one source file and outputs the object files to the same directory, and gcovr correctly generated everything. |
I think you're possibly right about the windows drive names being inconsistent @latk , I hacked the code a bit to normalise all of the drive names to have the same case and I get coverage data correctly. Initially I tried setting them to always be upper case (e.g. c:\bla\bla to C:\bla\bla), but that didn't work, as it seems that the root parameter is coming in to the compiled root_filter regex as lower case. So I then tried setting all of the paths (currdir, data_fname, source_fname, root_dir and fname) to have lower case drive names and everything seems fine. I'm not a great programmer so it's not a brilliant fix, so I won't try and set up a push request, don't worry! Here's the new output log including some debugging prints I put in to see what was going on: (Turns out I wasn't getting very good coverage) |
It doesn't matter if it's a “brilliant” fix. If it fixes a bug, I'd like to have it – even if only to see where you had to insert checks. I'm still a bit confused why these lower-case drive letters even enter the system. The root filter is obtained from doing an Which Python version are you using? |
I have a similar issue but actually get less output. I'm using a rather large cmake oos build,
Except while gcovr managed to read 140 gcno/gcda files it seems to think none of them match my source folder. I've also tried various combinations of I've also had gcovr open in the pycharm debugger and to me it looks like that gcovr doesn't manage to find the source file and then runs gcov, gcov then simply prints it's usage message and no output |
@inorton It sometimes helps to run gcovr from your build directory, and point the If not, please open a separate issue in which you also include your OS, Python version, gcovr version, and the gcovr output when running with the If you can create a minimal CMake project that demonstrates these problems, I could turn that into a test case and think about a fix. This would be most helpful. There are many complaints in connection with CMake, but so far no one has provided a clear test case that I can work with. |
Hi @latk , I'm sorry to bother you again, but I'm getting things set up so I can put the fixes in and create a pull request, but I'm struggling a little bit to get all of the tests passing on my windows development machine. It seems that a number of the tests fall over because the run function can't pick up make from the environment. I can't see anything about this listed in the contribution guidelines, and I've had a look at the gcovr CI and it looks like everything is OK there, is there anything I need to do to make sure that the tests can correctly pick up what's in my %PATH% ? The specific error is: E AssertionError: assert False I'm running the tests from MinGW bash using 'python -m pytest -v' inside the test directory. Thanks! |
@landofcake Unfortunately I'm not very familiar with Windows myself. There were similar problems when we added Appveyor builds, see #189. I think we had to set a If you have difficulty testing locally, you can sign up for Travis CI and Appveyor for your fork, then look at their build results when you push. What I do:
This isn't very efficient, but it works. You can prevent smaller mistakes by running flake8 and Please let me know if there's anything else I can help you with. |
Thanks for the information @latk , I've been experimenting and I'm now close to getting all of the tests working correctly in my Windows MinGW environment. The main issues are:
There are a few more failures left caused by some regressions in the coverage output, so I'll investigate these next. |
@landofcake Thank you, this info is useful and I'll update the contribution guide at some point. Don't bother putting too much effort in the failing tests, as you can just exclude them for now: |
I just found that this issue had previously been reported as #86. The solution there was to add a
|
Hey @latk , I had a bit of a play with this, and it seems that if you wholesale normcase() everything as it comes in it seems to play some strange games with some of the regex matching which I haven't perfectly worked out yet. The approach I have which works currently is to specifically sanitise the windows drive letter and keep the rest of the paths as the original case. Specifically, the following call:
(Actually the ~ isn't strictly necessary here, I was testing to see whether we also need to sanitise windows drive letters at the start of data_fname as well, but it doesn't appear to be necessary). Using this approach and sanitising all of the paths when we're inside process_gcov_data appears to allow everything to work correctly on my example. Specifically, I've sanitised:
One interesting thing I discovered is that in some of the tests we can get into process_gov_data with source_fname being None (e.g. html-nested2-use-existing). Is this intentional? |
Current status is that this is nearly passing all of the tests, I'm having some slightly strange windows related test issues ... specifically:
I guess this can probably be dropped into a separate issue report which I'll do when I've got time. |
Hello from the future! I have managed to get gcov and gcovr to play well with cmake by setting the correct compiler flags.
Set these in my own toolchain or early in your cmakelists. This gives me gcno files in my cmake build folder (next to .o files) and when I run my unit tests the gcda files appear there too. You then simply need to run gcovr inside your sources root (not your build folder)
|
I think
Not sure about the explicit |
@blueyed in later gcc |
I am trying the approach described by @inorton using gcovr 4.1 on my project but still get an empty report. Any suggestions how I can debug this? Update: Using the #!/usr/bin/bash
exec llvm-cov-9.0 gcov "$@" With that, the approach works fine for me. |
I close the issue since our tests are running with cmake and the actions are also running under Windows. |
Uh oh!
There was an error while loading. Please reload this page.
This is a follow on issue ticket from #64, as I'm currently experiencing exactly the same issue, and I can't for the life of me make gcovr correct pick up any coverage data from any gcov data generated from a standard CMake structured build (created in CLion). I am using Windows 10, with my code being built using the MinGW/MSYS g++ package. I am invoking gcovr from MinGW bash.
In my configuration, I've set the correct gcov compiler flags and managed to get output gcda and gcno files from a compile and test run.
The project is structured like this:
Project Root
________Subproject1
________________src
________________________(cpp files end up here)
________________include
________________________(h files end up here)
________Subproject2
________Subproject3
CMake automatically does it's business to generate makefiles for the build, and on build, it creates an output setup like this (where cmake-build-test is the build configuration I've set up which builds using the correct compiler flags for coverage).
Project Root
________cmake-build-test
________________Subproject1
________________________CMakeFiles
________________________________${Subproject1name}.dir
________________________________________src
________________________________________________(gcno and gcda files end up here)
________________Subproject2
________________Subproject3
I've tried multiple different combinations of the --root option, and I've tried collating the gcda and gcno files in a separate directory to no avail.
I've attached the log from a run of gcovr using the following:
gcovr -v -r .
I ran this from inside the project root (for reference, in the logs, it's C:\dev\hs\MSN, and the subproject directories are C:\dev\hs\MSN\MSN, C:\dev\hs\MSN\MSNTest, C:\dev\hs\MSN\MSNLib).
It may be that I'm simply not understanding the specifics of how the root flag is supposed to be used, but if this is genuinely a problem with what should be a supported setup, please let me know if there's any more useful information I can provide.
The text was updated successfully, but these errors were encountered: