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

[Bug]: Coverage report is empty #517

Open
bu3 opened this issue Jan 27, 2025 · 2 comments
Open

[Bug]: Coverage report is empty #517

bu3 opened this issue Jan 27, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@bu3
Copy link

bu3 commented Jan 27, 2025

What happened?

When I run the command bazel coverage --action_env=VERBOSE_COVERAGE=true --combined_report=lcov -- any_test_target, I see empty dat files getting created for the _test.py files and bazel prints out the following log

INFO: From Coverage report generation:
Jan 27, 2025 11:50:39 A.M. com.google.devtools.coverageoutputgenerator.Main getTracefiles
INFO: Found 1 tracefiles.
Jan 27, 2025 11:50:39 A.M. com.google.devtools.coverageoutputgenerator.Main parseFilesSequentially
INFO: Parsing file bazel-out/darwin_arm64-fastbuild/testlogs/projects/libs/examples/calculator/calculator_test/coverage.dat
Jan 27, 2025 11:50:39 A.M. com.google.devtools.coverageoutputgenerator.Main getGcovInfoFiles
INFO: No gcov info file found.
Jan 27, 2025 11:50:39 A.M. com.google.devtools.coverageoutputgenerator.Main getGcovJsonInfoFiles
INFO: No gcov json file found.
Jan 27, 2025 11:50:39 A.M. com.google.devtools.coverageoutputgenerator.Main getProfdataFileOrNull
INFO: No .profdata file found.
Jan 27, 2025 11:50:39 A.M. com.google.devtools.coverageoutputgenerator.Main runWithArgs
WARNING: There was no coverage found.
Target //projects/libs/examples/calculator:calculator_test up-to-date:
  bazel-bin/projects/libs/examples/calculator/calculator_test
  bazel-bin/projects/libs/examples/calculator/calculator_test.venv.pth

eventually the combined report bazel-out/_coverage/_coverage_report.dat is empty too.

Version

Development (host) and target OS/architectures:

Output of bazel --version: bazel 8.0.0

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file: aspect_rules_py 1.2.1

Language(s) and/or frameworks involved: python

How to reproduce

I made this repro repository to show my issue:
https://github.com/bu3/rules_python_repro/tree/main

at the root of the repo, you can find the script `run_code_coverage.sh` which runs the command I described above and check for the content of the combined report

Any other information?

No response

@bu3 bu3 added the bug Something isn't working label Jan 27, 2025
@bu3
Copy link
Author

bu3 commented Jan 27, 2025

I noticed this mentioning py_pytest_main so I have added that too to my BUILD file along with the coverage and pytest dependencies.

Still the report results empty

@bu3
Copy link
Author

bu3 commented Jan 27, 2025

NVM I ran gazelle after adding py_pytest_main to the BUILD file and now the report contains data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant