Include reportGeneratorExec's runfiles as action inputs
The combination of `--coverage_report_generator` with `--disk_cache` led to
a `java.lang.IllegalStateException` in `ActionMetadataHandler.getMetadata`,
seemingly because `CoverageReportActionBuilder`'s report generator
can have an (until now) undeclared runfiles tree.  Fix that by declaring the
latter.
Resolves
Closes
@@ -39,6 +39,7 @@ import com.google.devtools.build.lib.actions.SpawnResult;
import com.google.devtools.build.lib.analysis.BlazeDirectories;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.FilesToRunProvider;
+import com.google.devtools.build.lib.analysis.RunfilesSupport;
import com.google.devtools.build.lib.analysis.actions.FileWriteAction;
import com.google.devtools.build.lib.analysis.test.CoverageReportActionFactory.CoverageReportActionsWrapper;
import com.google.devtools.build.lib.analysis.test.TestProvider;
@@ -242,17 +243,21 @@ public final class CoverageReportActionBuilder {
Artifact lcovOutput = args.factory().getDerivedArtifact(
coverageDir.getRelative("_coverage_report.dat"), root, args.artifactOwner());
Artifact reportGeneratorExec = args.reportGenerator().getExecutable();
+ RunfilesSupport runfilesSupport = args.reportGenerator().getRunfilesSupport();
args = CoverageArgs.createCopyWithCoverageDirAndLcovOutput(args, coverageDir, lcovOutput);
ImmutableList<String> actionArgs = argsFunc.apply(args);
- ImmutableList<Artifact> inputs = ImmutableList.<Artifact>builder()
+ ImmutableList.Builder<Artifact> inputsBuilder =
+ ImmutableList.<Artifact>builder()
.addAll(args.coverageArtifacts())
.add(reportGeneratorExec)
- .add(args.lcovArtifact())
- .build();
+ .add(args.lcovArtifact());
+ if (runfilesSupport != null) {
+ inputsBuilder.add(runfilesSupport.getRunfilesMiddleman());
+ }
return new CoverageReportAction(
ACTION_OWNER,
- inputs,
+ inputsBuilder.build(),
ImmutableList.of(lcovOutput),
actionArgs,
locationFunc.apply(args),
