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
Exclude flag broken on Windows #191
Comments
Look at Pull Request #158. This patch solved similar problems for me. |
This will be fixed once #158 is merged. But even then, the filter is slightly incorrect because the current working directory is prepended. I.e. you would actually end up with this regex:
The alternation
(the trailing In the mid term, I think ALL filters need to be redesigned and/or clarified (see also #151). Some operate on relative paths, some on absolute paths, some regexes like this one are prepended with a path, …. So at the very least this is a documentation bug, independent from #158. |
@wolf99 It seems that you call gcovr directly from command line on Windows. How did you do that? my
|
@goriy I added the |
@wolf99 I had tried that way too. Yes, it worked, but I decided that it's a bit better to create additional file only once without manual renaming every upgrade. I hoped you could find some way to run gcovr without renaming... I've seen some python packages which install .exe wrapper into |
I have merged #158 and am trying to figure out how to make the tests on Windows run (#189). All that's missing is the filter-related tests. Thanks to #158 filters are now constructed in an unified manner. Unfortunately, #158 introduced a slight regression because it assumes filters are relative paths. The filter-test2 and #137 show the intent that filters can be absolute paths: GCOVR_TEST_OPTIONS = -f `pwd`'/main.cpp' If that test were adapted to use native Windows paths, we'd get This raises a choice:
In both cases will a Windows path have to be adapted. Currently, absolute paths don't work under Windows, but relative paths with escaped backslashes do. Cygwin-style paths I think requiring forward slashes is the better solution. This will break a few scripts. But it provides a clear mental model that's easy to communicate: “filters must use forward slashes, even on Windows”. Pseudocode for filter matching then becomes: def normalize_path(path):
return os.path.realpath(path).replace(os.path.sep, '/')
def match(filter, path):
path = normalize_path(path)
if not os.path.isabs(filter):
filter = re.escape(normalize_path(os.getcwd())) + '/' + filter
return re.match(filter, path) This code should work on both Windows and Unixish systems. The current solution of feeding regex patterns into What are your thoughts on this? @denniswjackson I'd also be interested in your perspective. |
Generally I don't like the first case (where it's allowed to use backslashes as path separators in filters) because there's no way to distinguish between path separator and regex escape. Second case seems much more attractive to me. I think that it's not a big problem to use only forward slashes as path separators in filters. Although they seem less "native" on Windows, but escaped double-backslashes seem even worse! It's impossible to use native windows paths "as is" anyway. And I consider it a great advantage to be able to use the same scripts on different platforms. As a result I agree that requiring forward slashes is the better solution. |
I agree that the second option is more immediately attractive, even just from a visual standpoint. To play devil's advocate though, if I was a Windows-native developer, I might simply copy and paste the path from Windows Explorer or the Command Prompt - which would include back slashes and be wrong for both options thus leaving the hypothetical me confused. Not to say that Gcovr should support such a scenario, but are there other cross platform Python scripts that also deal with regex input that we could look at to see how they expect such input and how it is managed there? |
Hi, sorry if my question is dumb, but how are we suppose to use this exclude filter now on windows? can someone give an example? I am new to gcovr, and I dont know much about regex. I have a gtest setup and want to exclude all my gtest framework code, I tried the following, but none were working:
Thanks in advance |
@dennykhoerniawan That's actually a very good question! Unfortunately, filtering is a bit of a mess. For a moment I thought the new The
But this will not:
Please report your results, because I'm not 100% sure about this myself. If this didn't work, please create a new issue where you explain
Thank you for your help. Without these reports, I wouldn't know about all the stuff that needs fixing :) |
I have finally implemented a new filtering system, see #257. Filters now use forward slashes on all systems incl. Windows. Please test & critique the design. Once that PR is merged, I intend to prepare a gcovr 4.0 release. |
Ok, PR #257 (filter redesign) has been merged 🎉 |
Well done @latk, you've been putting in a lot of hard work on gcovr - it is much appreciated by those of us that use it! |
Since #152 was merged it seems like gcov is now generating detailed HTML reports on Windows. So the following works as expected - yay! 🙌
However it appears that the exclude flag is now broken:
The text was updated successfully, but these errors were encountered: