Hi, all! I have a `.coverage.1` file from the firs...
# general
b
Hi, all! I have a
.coverage.1
file from the first target and a
.coverage.2
file from the second:
Copy code
Name                                                             Stmts   Miss  Cover
------------------------------------------------------------------------------------
target1                                                            28      0   100%

Name                                                Stmts   Miss  Cover
-----------------------------------------------------------------------
target2                                              109     24    78%
I want to combine these 2 files. As I understand it, I can't do this with the help of pants. When trying to do this with the help of pure coverage:
Copy code
./pants run :coverage -- combine --rcfile=src/coverage.rc dist_pants/coverage/python
./pants run :coverage -- report --rcfile=src/coverage.rc
I get:
Copy code
Name                                                             Stmts   Miss  Cover
------------------------------------------------------------------------------------
target1                                                            28     28     0%
target2                                                           109    109     0%
If I try to get only a report, I get the same result:
Copy code
./pants run :coverage -- report --rcfile=src/coverage.rc --data-file=dist_pants/coverage/python/.coverage.2

Name                                                Stmts   Miss  Cover
-----------------------------------------------------------------------
target2                                              109    109     0%
My config(
coverage.rc
) looks like this:
Copy code
[report]
exclude_lines =
    pragma: no cover

skip_empty = True

[paths]
src =
    src/
    .pants.d/pyprep/sources/*/src
    /root/app/.pants.d/pyprep/sources/*/src
What am I missing? Is there an analogue of the
coverage combine
and
coverage report
commands in pants? Pants: v2.14, coverage: v7.2.7
b
Hi. I don't know specifics about
coverage
, but just checking that you've seen https://www.pantsbuild.org/docs/python-test-goal#coverage . Does that provide any insight?
b
Actually, I've looked at this page many times, but for some reason only this time I noticed this text there:
Copy code
You may use a Coverage config file, e.g. .coveragerc or pyproject.toml. Pants will autodiscover the config file for you, and you can also set [coverage-py].config in your pants.toml to point to a non-standard location. You must include relative_files = true in the [run] section for Pants to work.
so I just added
relative_files = true
to my coveragerc config file. I don't quite understand what exactly this setup does, but in any case, this was the solution. So thank you, Huon!
b
Ah, sorry for telling you things you already know, but I'm glad you could find the hidden bit of advice. It seems strange that such an important piece of advice is not highlighted more obviously! If you have a moment, could you file a bug about making that limitation more obvious? https://github.com/pantsbuild/pants/issues/new?assignees=&labels=bug&projects=&template=bug_report.md&title=
b
b
Thank you!
👍 1