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

--include or --exclude options doesn't seem to work at all #145

Open
HerbertKoelman opened this issue Jun 8, 2019 · 3 comments
Open

--include or --exclude options doesn't seem to work at all #145

HerbertKoelman opened this issue Jun 8, 2019 · 3 comments

Comments

@HerbertKoelman
Copy link

For example this excludes nothing:

coveralls --dryrun --root CMakeFiles/ --exclude-pattern "/usr/.*" --exclude-pattern "*.gtest.*"

According to the somewhat absent documentation, you would expect:

  • everything that starts with /usr/ should be excluded, but it's not
  • everything that contains gtest should be exclude, but it's not
@adam-stamand
Copy link

I'm having the same issue, --exclude-pattern is not excluding any of the directories I specify.

@adam-stamand
Copy link

adam-stamand commented Aug 15, 2019

I've spent a while playing with it, and got it to work for my needs. For anyone who's struggling like I did:

  • Ensure you set the root to the project root ( using the -r option). cpp-coveralls has a segment of code that discards parent directories, so if the root is set to a project subdirectory, you won't be able to get coverage on the rest of the project.

  • The excluding options apply to different stages of processing, confusingly.

    • The --exclude option will prevent files/directories from being run with gcov. Keep in mind the directories are relative to the root that you set with the -r option, even though gcov will print out paths such as "/usr/foo/bar.cpp".
    • The --exclude-pattern option is not used to determine what gets run with gcov, but instead it is used to filter out specific files/directories from being included in the report that gets sent to coveralls.io.
  • The --include option, similar to the --exclude-pattern option, is used to select specific files/directories to be included in the report. The --include option does not effect what gets run with gcov.

For my project, I have unit tests (using GTest), an example program, and benchmarking. To prevent cpp-coveralls from getting coverage of my example program and only get coverage using my unit tests, I had to be specific in my --exclude. Below is what I used in my .travis.yml to get coverage working for my project:

coveralls -r .. -i "src/" -i "test/" --exclude "utils" --exclude "benchmark" --exclude "example" --exclude "build/CMakeFiles/memory_allocator.dir/" --gcov-options '-lp' --verbose

If you want to reference anything from my project, you can find it here https://github.com/adam-stamand/memory-allocators. Hope this helps somebody.

equalsraf pushed a commit to equalsraf/neovim-qt that referenced this issue Jun 21, 2020
cpp-coveralls -e exclude rules prevent gcov from being executed, which
is not what we need, e.g.

    eddyxu/cpp-coveralls#145 (comment)

we want to exclude from the coverage reports

- autogenerated Qt/CMake code
- test code
- code from third-party/

This can be done as exclusion (python) regular expressions.
@sdarwin
Copy link

sdarwin commented Sep 17, 2022

Which of "--exclude", "--exclude-pattern", or "--exclude-lines-pattern" would work in conjunction with the -l FILE option?

-l FILE, --lcov-file FILE
                        Upload lcov generated info file

I have a pre-existing coverage.info file. Uploading it with cpp-coveralls. Trying to exclude files with "--exclude-pattern".

The fix seems to be lcov --remove filename instead of using cpp-coveralls, for that particular step.

It would be great if @adam-stamand (or someone else) could add a new paragraph in the README that more verbosely clarifies the differences between "--exclude", "--exclude-pattern" and "--exclude-lines-pattern", since the description of all three seems to be "exclude file or directory".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants