use of com.google.devtools.build.lib.rules.test.BaselineCoverageAction in project bazel by bazelbuild.
the class BuildViewTestCase method baselineCoverageArtifactBasenames.
protected Iterable<String> baselineCoverageArtifactBasenames(ConfiguredTarget target) throws Exception {
ImmutableList.Builder<String> basenames = ImmutableList.builder();
for (Artifact baselineCoverage : target.getProvider(InstrumentedFilesProvider.class).getBaselineCoverageArtifacts()) {
BaselineCoverageAction baselineAction = (BaselineCoverageAction) getGeneratingAction(baselineCoverage);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
baselineAction.newDeterministicWriter(ActionsTestUtil.createContext(reporter)).writeOutputFile(bytes);
for (String line : new String(bytes.toByteArray(), StandardCharsets.UTF_8).split("\n")) {
if (line.startsWith("SF:")) {
String basename = line.substring(line.lastIndexOf('/') + 1);
basenames.add(basename);
}
}
}
return basenames.build();
}
Aggregations