Skip to content

Commit

Permalink
Check for both :lcov_merger and $lcov_merger attributes in TestAction…
Browse files Browse the repository at this point in the history
…Builder.

384e1cb renamed an attribute from `$lcov_merger` to `:lcov_merger`, which is a breaking change and broke rules_go. This PR changes the test runner to check both attribute names for backwards compatibility. The next step is to introduce an incompatible flag to remove the former.

Fixes bazelbuild#8670

Closes bazelbuild#8709.

PiperOrigin-RevId: 254915099
  • Loading branch information
iirina authored and siberex committed Jul 4, 2019
1 parent 34c1ba7 commit a0c6046
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,15 @@ private TestParams createTestAction(int shards) {
extraTestEnv.put(BAZEL_CC_COVERAGE_TOOL, GCOV_TOOL);

// We don't add this attribute to non-supported test target
String lcovMergerAttr = null;
if (ruleContext.isAttrDefined(":lcov_merger", LABEL)) {
lcovMergerAttr = ":lcov_merger";
} else if (ruleContext.isAttrDefined("$lcov_merger", LABEL)) {
lcovMergerAttr = "$lcov_merger";
}
if (lcovMergerAttr != null) {
TransitiveInfoCollection lcovMerger =
ruleContext.getPrerequisite(":lcov_merger", Mode.TARGET);
ruleContext.getPrerequisite(lcovMergerAttr, Mode.TARGET);
FilesToRunProvider lcovFilesToRun = lcovMerger.getProvider(FilesToRunProvider.class);
if (lcovFilesToRun != null) {
extraTestEnv.put(LCOV_MERGER, lcovFilesToRun.getExecutable().getExecPathString());
Expand All @@ -286,7 +292,7 @@ private TestParams createTestAction(int shards) {
inputsBuilder.add(lcovMergerArtifact);
} else {
ruleContext.attributeError(
":lcov_merger",
lcovMergerAttr,
"the LCOV merger should be either an executable or a single artifact");
}
}
Expand Down

0 comments on commit a0c6046

Please sign in to comment.