Skip to content

Commit

Permalink
[bazelbuild#6764] Fix coverage display when running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mtoader committed Sep 17, 2024
1 parent 2fd56e9 commit e444a2f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ public static BlazeInfo create(
ExecutionRootPath.createAncestorRelativePath(
executionRoot, new File(getOrThrow(blazeInfoMap, blazeTestlogsKey(buildSystemName))));
File outputBase = new File(getOrThrow(blazeInfoMap, OUTPUT_BASE_KEY).trim());
File outputPath = new File(getOrThrow(blazeInfoMap, OUTPUT_PATH_KEY).trim());
return AutoValue_BlazeInfo.builder()
.setBlazeInfoMap(blazeInfoMap)
.setExecutionRoot(executionRoot)
.setBlazeBin(blazeBin)
.setBlazeGenfiles(blazeGenfiles)
.setBlazeTestlogs(blazeTestlogs)
.setOutputBase(outputBase)
.setOutputPath(outputPath)
.autoBuild();
}

Expand Down Expand Up @@ -140,6 +142,8 @@ public File getBlazeTestlogsDirectory() {

public abstract File getOutputBase();

public abstract File getOutputPath();

public String getStarlarkSemantics() {
return getBlazeInfoMap().get(STARLARK_SEMANTICS);
}
Expand All @@ -160,6 +164,7 @@ public static BlazeInfo createMockBlazeInfo(
ImmutableMap.Builder<String, String> blazeInfoMap =
ImmutableMap.<String, String>builder()
.put(OUTPUT_BASE_KEY, outputBase)
.put(OUTPUT_PATH_KEY, outputBase + "/output")
.put(EXECUTION_ROOT_KEY, executionRoot)
.put(blazeBinKey(buildSystemName), blazeBin)
.put(blazeGenfilesKey(buildSystemName), blazeGenFiles)
Expand All @@ -181,12 +186,15 @@ public abstract static class Builder {

public abstract Builder setOutputBase(File value);

public abstract Builder setOutputPath(File value);

public abstract BlazeInfo autoBuild();

// A build method to populate the blazeInfoMap
public BlazeInfo build(BuildSystemName buildSystemName) {
BlazeInfo blazeInfo = autoBuild();
blazeInfoMapBuilder().put(OUTPUT_BASE_KEY, blazeInfo.getOutputBase().getPath());
blazeInfoMapBuilder().put(OUTPUT_PATH_KEY, blazeInfo.getOutputPath().getPath());
blazeInfoMapBuilder().put(EXECUTION_ROOT_KEY, blazeInfo.getExecutionRoot().getPath());
File execRoot = new File(blazeInfo.getExecutionRoot().getAbsolutePath());
blazeInfoMapBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static ImmutableList<String> getBlazeFlags() {
}

public static File getOutputFile(BlazeInfo blazeInfo) {
File coverageRoot = new File(blazeInfo.getOutputBase(), "_coverage");
File coverageRoot = new File(blazeInfo.getOutputPath(), "_coverage");
return new File(coverageRoot, "_coverage_report.dat");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public class FastBuildChangedFilesServiceTest extends BlazeIntegrationTestCase {
"blaze-genfiles", BLAZE_EXECROOT + "/blaze-genfiles",
"blaze-testlogs", BLAZE_TESTLOGS,
"execution_root", BLAZE_EXECROOT,
"output_base", "/blaze/output-base"));
"output_base", "/blaze/output-base",
"output_path", "/blaze/output-base/output-path"
));

private FastBuildChangedFilesService changedFilesService;
private ArtifactLocationDecoder artifactLocationDecoder;
Expand Down

0 comments on commit e444a2f

Please sign in to comment.