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

[5.4.0]Fix identical gcov json file name problem #16672

Merged
merged 1 commit into from
Nov 8, 2022

Conversation

krisukox
Copy link
Contributor

@krisukox krisukox commented Nov 7, 2022

The problem:

Bazel moves all .gcov.json.gz files to one directory. If in a test target, two source files have identical names, then the second .gcov.json.gz overwrites the first one.

The solution:

I added gcno_path to the move destination in order to distinguish multiple .gcov.json.gz with the same name.

Testing:

In the test_cc_test_coverage_gcov test case I added the different/a.cc source file, so currently we have the following source tree:

coverage_srcs/a.h
coverage_srcs/a.cc
coverage_srcs/b.h
coverage_srcs/t.cc
coverage_srcs/different/a.h
coverage_srcs/different/a.cc

gcda and gcno files are created next to the source files. The final gcov.json files are placed in the corresponding paths:

$COVERAGE_DIR_VAR/coverage_srcs/*a.gcov.json.gz
$COVERAGE_DIR_VAR/coverage_srcs/*t.gcov.json.gz
$COVERAGE_DIR_VAR/coverage_srcs/different/*a.gcov.json.gz

Closes #16527.

PiperOrigin-RevId: 483911427
Change-Id: I1608407e4b7264fb5fd436997bdc344344932b97

**The problem:**

Bazel moves all `.gcov.json.gz` files to one directory. If in a test target, two source files have identical names, then the second `.gcov.json.gz` overwrites the first one.

**The solution:**

I added `gcno_path` to the move destination in order to distinguish multiple `.gcov.json.gz` with the same name.

**Testing:**

In the `test_cc_test_coverage_gcov` test case I added the `different/a.cc` source file, so currently we have the following source tree:
```
coverage_srcs/a.h
coverage_srcs/a.cc
coverage_srcs/b.h
coverage_srcs/t.cc
coverage_srcs/different/a.h
coverage_srcs/different/a.cc
```

gcda and gcno files are created next to the source files. The final `gcov.json` files are placed in the corresponding paths:
```
$COVERAGE_DIR_VAR/coverage_srcs/*a.gcov.json.gz
$COVERAGE_DIR_VAR/coverage_srcs/*t.gcov.json.gz
$COVERAGE_DIR_VAR/coverage_srcs/different/*a.gcov.json.gz
```

Closes bazelbuild#16527.

PiperOrigin-RevId: 483911427
Change-Id: I1608407e4b7264fb5fd436997bdc344344932b97
@krisukox krisukox marked this pull request as ready for review November 7, 2022 16:02
@ShreeM01 ShreeM01 added team-Rules-CPP Issues for C++ rules awaiting-review PR is awaiting review from an assigned reviewer potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone and removed awaiting-review PR is awaiting review from an assigned reviewer potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone labels Nov 7, 2022
@meteorcloudy
Copy link
Member

@krisukox Can you explain why do you want to cherry pick this change to 5.4.0?

@krisukox
Copy link
Contributor Author

krisukox commented Nov 8, 2022

Code coverage is very inaccurate if a code base has multiple files with the same name. This is a crucial bug fix for code coverage.

@meteorcloudy
Copy link
Member

@krisukox Thanks!

@meteorcloudy meteorcloudy enabled auto-merge (squash) November 8, 2022 09:40
@meteorcloudy meteorcloudy merged commit fc08f55 into bazelbuild:release-5.4.0 Nov 8, 2022
@ShreeM01 ShreeM01 modified the milestone: 5.4.0 release blockers Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Rules-CPP Issues for C++ rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants