question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No coverage data if testing code from external repositories

See original GitHub issue

Description of the bug:

Using software and tests in the same repository is no problem, coverage data are produced. Splitting the two makes problems. There is “no coverage data” produced anymore. It seems that coverage data is generated, but not consumed, maybe because of some path issue/mismatch. If I also instrument the tests, the test’s coverage will be copied into the combined coverage file, but still no software coverage.

What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Minimal example in this test repo. This will use this software repo and produce no coverage.

Simply check it out and run

bazel coverage -c dbg --combined_report=lcov --instrumentation_filter="@sw_repo//:funclib" --action_env=COVERAGE_GCOV_OPTIONS=-b //:mytest

This will say WARNING: There was no coverage found.

Which operating system are you running Bazel on?

Debian (WSL2)

What is the output of bazel info release?

release 5.3.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What’s the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

I did not find anything searching.

In this Slack discussion I was encouraged to create an issue.

Any other information, logs, or outputs that you want to share?

I can see in the testlog that coverage info is build. Then it is processed but no data is found.

Executing tests from //:mytest
-----------------------------------------------------------------------------
File 'test/test.c'
Lines executed:83.33% of 6
Branches executed:100.00% of 2
Taken at least once:50.00% of 2
Calls executed:50.00% of 2

Creating 'test.pic.gcov.json.gz'
Lines executed:83.33% of 6
File 'external/sw_repo/sw/func.c'
Lines executed:53.85% of 13
Branches executed:100.00% of 3
Taken at least once:33.33% of 3
No calls

Creating 'func.pic.gcov.json.gz'
Lines executed:53.85% of 13
Sep 02, 2022 7:49:56 PM com.google.devtools.coverageoutputgenerator.Main getTracefiles
INFO: No lcov file found.
Sep 02, 2022 7:49:56 PM com.google.devtools.coverageoutputgenerator.Main getGcovInfoFiles
INFO: No gcov info file found.
Sep 02, 2022 7:49:56 PM com.google.devtools.coverageoutputgenerator.Main getGcovJsonInfoFiles
INFO: Found 2 gcov json files.
Sep 02, 2022 7:49:56 PM com.google.devtools.coverageoutputgenerator.Main parseFilesSequentially
INFO: Parsing file /home/lukas/.cache/bazel/_bazel_lukas/7da12e39a3158a3f59d65f10c3647c59/sandbox/linux-sandbox/13/execroot/test_repo/_coverage/mytest/test/test.pic.gcov.json.gz
Sep 02, 2022 7:49:56 PM com.google.devtools.coverageoutputgenerator.Main parseFilesSequentially
INFO: Parsing file /home/lukas/.cache/bazel/_bazel_lukas/7da12e39a3158a3f59d65f10c3647c59/sandbox/linux-sandbox/13/execroot/test_repo/_coverage/mytest/test/func.pic.gcov.json.gz
Sep 02, 2022 7:49:56 PM com.google.devtools.coverageoutputgenerator.Main getProfdataFileOrNull
INFO: No .profdata file found.
Sep 02, 2022 7:49:56 PM com.google.devtools.coverageoutputgenerator.Main runWithArgs
WARNING: There was no coverage found.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
susinmotioncommented, Nov 14, 2022

We’re rolling #16637 back since it’s breaking some internal tests 😦 Reopening to keep track of it again.

0reactions
fmeumcommented, Nov 17, 2022

@celkas That’s always going to be a problem as external repositories aren’t materialized in your workspace, they only exist under the Bazel output base. Does genhtml let you specify additional source roots? If so, you could use that instead of the symlink. If there isn’t, some sed or the symlink is going to be your best bet.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Test coverage visualization - GitLab Docs
The test-jdk11 job tests the code and generates an XML artifact. ... If the test coverage visualization is not displayed in the diff...
Read more >
How can I make phpunit do code-coverage on an external ...
I want to have PhpUnit tests in one git repository and the code being tested in another one. Q: May I do code-coverage?...
Read more >
Code coverage for pull requests - Azure Pipelines
The status check evaluates the diff coverage value for all the code files in the pull request. If you would like to view...
Read more >
What Code Is Deliberately Excluded from Test Coverage and ...
During this process, ideally, the coverage analysis should be as clean as possible to avoid noisy data: “Not all code is equally important,...
Read more >
Where do data files for unit tests belong, external or in-project ...
The test data belongs to the tests. As such, it should be versioned at the same time. The best reasons I find for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found