Verify that --use_action_cache works with merged Skyframe phases.
It has basically been working all along: we have the appropriate setup steps for the Action Cache.
PiperOrigin-RevId: 419733401
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
index 0875b92..5f2969b 100644
--- a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
+++ b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
@@ -243,12 +243,14 @@
*
* <p>b/199053098: This method concentrates the setup steps for execution, which were previously
* scattered over several classes. We need this in order to merge analysis & execution phases.
- * TODO(b/199053098): Minimize code duplication with the main code path.
+ * TODO(b/199053098): Minimize code duplication with the main code path. TODO(b/213040766): Write
+ * tests for these setup steps.
*/
public void prepareForExecution(
UUID buildId, Set<ConfiguredTargetKey> builtTargets, Set<AspectKey> builtAspects)
throws AbruptExitException, BuildFailedException, InterruptedException {
init();
+ BuildRequestOptions options = request.getBuildOptions();
SkyframeExecutor skyframeExecutor = env.getSkyframeExecutor();
// TODO(b/199053098): Support symlink forest.
@@ -284,8 +286,11 @@
createActionLogDirectory();
}
- ActionCache actionCache = getActionCache();
- actionCache.resetStatistics();
+ ActionCache actionCache = null;
+ if (options.useActionCache) {
+ actionCache = getActionCache();
+ actionCache.resetStatistics();
+ }
SkyframeBuilder skyframeBuilder;
try (SilentCloseable c = Profiler.instance().profile("createBuilder")) {
skyframeBuilder =
diff --git a/src/test/shell/integration/merged_skyframe_phases_test.sh b/src/test/shell/integration/merged_skyframe_phases_test.sh
index f00e77c..8ac19f6 100755
--- a/src/test/shell/integration/merged_skyframe_phases_test.sh
+++ b/src/test/shell/integration/merged_skyframe_phases_test.sh
@@ -85,7 +85,7 @@
EOF
cp foo/foo.cc foo/bar.cc
- bazel build --nouse_action_cache --experimental_merged_skyframe_analysis_execution //foo:all &> "$TEST_log" || fail "Expected success"
+ bazel build --experimental_merged_skyframe_analysis_execution //foo:all &> "$TEST_log" || fail "Expected success"
}
function test_failed_builds() {
@@ -121,23 +121,23 @@
touch foo/foo.cc
touch foo/bar.cc
- bazel build --nouse_action_cache --experimental_merged_skyframe_analysis_execution //foo:execution_failure &> "$TEST_log" && fail "Expected failure"
+ bazel build --experimental_merged_skyframe_analysis_execution //foo:execution_failure &> "$TEST_log" && fail "Expected failure"
exit_code="$?"
[[ "$exit_code" -eq 1 ]] || fail "Unexpected exit code: $exit_code"
expect_log "missing input file '//foo:missing.a'"
- bazel build --nouse_action_cache --experimental_merged_skyframe_analysis_execution //foo:analysis_failure &> "$TEST_log" && fail "Expected failure"
+ bazel build --experimental_merged_skyframe_analysis_execution //foo:analysis_failure &> "$TEST_log" && fail "Expected failure"
exit_code="$?"
[[ "$exit_code" -eq 1 ]] || fail "Unexpected exit code: $exit_code"
expect_log "Analysis of target '//foo:analysis_failure' failed"
- bazel build --nouse_action_cache --nokeep_going --experimental_merged_skyframe_analysis_execution //foo:analysis_failure //foo:execution_failure &> "$TEST_log" && fail "Expected failure"
+ bazel build --nokeep_going --experimental_merged_skyframe_analysis_execution //foo:analysis_failure //foo:execution_failure &> "$TEST_log" && fail "Expected failure"
exit_code="$?"
[[ "$exit_code" -eq 1 ]] || fail "Unexpected exit code: $exit_code"
# With --nokeep_going, technically nothing can be said about the message: whichever target fails first would abort the build.
- bazel build --nouse_action_cache --keep_going --experimental_merged_skyframe_analysis_execution //foo:analysis_failure //foo:execution_failure &> "$TEST_log" && fail "Expected failure"
+ bazel build --keep_going --experimental_merged_skyframe_analysis_execution //foo:analysis_failure //foo:execution_failure &> "$TEST_log" && fail "Expected failure"
exit_code="$?"
[[ "$exit_code" -eq 1 ]] || fail "Unexpected exit code: $exit_code"
expect_log "missing input file '//foo:missing.a'"