cool-easter-32542
06/27/2023, 9:23 AM./pants --no-local-cache test --test-use-coverage --coverage-py-report="raw" --coverage-py-config="src/coverage.rc" ${target}
(for each target, I renamed the coverage files so that they would not be overwritten: .coverage -> .coverage.1, ...)
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:
./pants run :coverage -- combine --rcfile=src/coverage.rc dist_pants/coverage/python
./pants run :coverage -- report --rcfile=src/coverage.rc
I get:
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:
./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:
[report]
exclude_lines =
pragma: no cover
skip_empty = True
[paths]
src =
src/
.pants.d/pyprep/sources/*/src
/root/app/.pants.d/pyprep/sources/*/src
And what I described above was solved after reading the following piece of documentation written here:
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.
And I just added relative_files = true to the config file. But from this description it is not clear to me exactly when to use the option: always when I use the config file or only when it is not in the standard location? And what kind of a non-standard location? Everything except root(project, pants)? In addition, it is not entirely clear how it works: after all, even without relative_files option the config file was read(for example, the init file was skipped) but at the same time, 'pure' coverage could not pull up the data created by 'pants' coverage and create a report
Pants version
Pants v2.14
Coverage v7.2.7
OS
Linux, Ubuntu 22.04
pantsbuild/pants