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

[6.0.0]Fix identical gcov json file name problem #16647

Merged
merged 1 commit into from
Nov 3, 2022

Conversation

krisukox
Copy link
Contributor

@krisukox krisukox commented Nov 3, 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 3, 2022 10:25
@ShreeM01 ShreeM01 added coverage team-Rules-CPP Issues for C++ rules awaiting-review PR is awaiting review from an assigned reviewer and removed coverage team-Rules-CPP Issues for C++ rules awaiting-review PR is awaiting review from an assigned reviewer labels Nov 3, 2022
@ShreeM01 ShreeM01 merged commit 5eb506b into bazelbuild:release-6.0.0 Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants