Remove only-in-tests null checks in SkyframeActionExecutor.
Still on step -0.5, let's be honest.
--
PiperOrigin-RevId: 150783638
MOS_MIGRATED_REVID=150783638
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
index 1396334..7c353ac 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
@@ -131,8 +131,10 @@
private boolean keepGoing;
private boolean hadExecutionError;
private ActionInputFileCache perBuildFileCache;
+ /** These variables are nulled out between executions. */
private ProgressSupplier progressSupplier;
private ActionCompletedReceiver completionReceiver;
+
private final AtomicReference<ActionExecutionStatusReporter> statusReporterRef;
private OutputService outputService;
@@ -393,9 +395,7 @@
// Tell the receiver that the action has completed *before* telling the reporter.
// This way the latter will correctly show the number of completed actions when task
// completion messages are enabled (--show_task_finish).
- if (completionReceiver != null) {
- completionReceiver.actionCompleted(action);
- }
+ completionReceiver.actionCompleted(action);
reporter.finishTask(null, prependExecPhaseStats(message));
}
}
@@ -658,14 +658,9 @@
}
private String prependExecPhaseStats(String message) {
- if (progressSupplier != null) {
- // Prints a progress message like:
- // [2608/6445] Compiling foo/bar.cc [host]
- return progressSupplier.getProgressString() + " " + message;
- } else {
- // progressSupplier may be null in tests
- return message;
- }
+ // Prints a progress message like:
+ // [2608/6445] Compiling foo/bar.cc [host]
+ return progressSupplier.getProgressString() + " " + message;
}
/**
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderTest.java
index 75dcc14..76667a3 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderTest.java
@@ -775,12 +775,12 @@
buildArtifacts(baz);
// Check that the percentages increase non-linearly, because foo has 10 input files
List<String> expectedMessages = Lists.newArrayList(
- "Test foo START",
- "Test foo FINISH",
- "Test bar START",
- "Test bar FINISH",
- "Test baz START",
- "Test baz FINISH");
+ " Test foo START",
+ " Test foo FINISH",
+ " Test bar START",
+ " Test bar FINISH",
+ " Test baz START",
+ " Test baz FINISH");
assertThat(messages).containsAllIn(expectedMessages);
// Now do an incremental rebuild of bar and baz,
@@ -792,10 +792,10 @@
// (in-memory) file system, rather than using cached entries.
buildArtifacts(baz);
expectedMessages = Lists.newArrayList(
- "Test bar START",
- "Test bar FINISH",
- "Test baz START",
- "Test baz FINISH");
+ " Test bar START",
+ " Test bar FINISH",
+ " Test baz START",
+ " Test baz FINISH");
assertThat(messages).containsAllIn(expectedMessages);
}
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java b/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java
index 46932ea..2ca64ea 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java
@@ -53,6 +53,8 @@
import com.google.devtools.build.lib.skyframe.ExternalFilesHelper.ExternalFileAction;
import com.google.devtools.build.lib.skyframe.PackageLookupFunction.CrossRepositoryLabelViolationStrategy;
import com.google.devtools.build.lib.skyframe.PackageLookupValue.BuildFileName;
+import com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.ActionCompletedReceiver;
+import com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.ProgressSupplier;
import com.google.devtools.build.lib.testutil.FoundationTestCase;
import com.google.devtools.build.lib.testutil.TestConstants;
import com.google.devtools.build.lib.testutil.TestRuleClassProvider;
@@ -242,6 +244,8 @@
false,
new ActionCacheChecker(actionCache, null, ALWAYS_EXECUTE_FILTER, null),
null);
+ skyframeActionExecutor.setActionExecutionProgressReportingObjects(
+ EMPTY_PROGRESS_SUPPLIER, EMPTY_COMPLETION_RECEIVER);
List<SkyKey> keys = new ArrayList<>();
for (Artifact artifact : artifacts) {
@@ -461,4 +465,18 @@
return actionTemplateExpansionFunction.extractTag(skyKey);
}
}
+
+ private static final ProgressSupplier EMPTY_PROGRESS_SUPPLIER =
+ new ProgressSupplier() {
+ @Override
+ public String getProgressString() {
+ return "";
+ }
+ };
+
+ private static final ActionCompletedReceiver EMPTY_COMPLETION_RECEIVER =
+ new ActionCompletedReceiver() {
+ @Override
+ public void actionCompleted(Action action) {}
+ };
}