Move execute implementation up to TestRunnerAction
Instead, add methods to TestActionContext to construct a TestRunnerSpawn
and inform about test_keep_going.
As of this point, the high-level test execution process is now shared
between Bazel and Blaze. This is in preparation for implementing async
test execution.
PiperOrigin-RevId: 236107062
diff --git a/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java b/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java
index 5ea50c6..28e636d 100644
--- a/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/exec/StandaloneTestStrategyTest.java
@@ -26,6 +26,7 @@
import com.google.common.collect.MoreCollectors;
import com.google.devtools.build.lib.actions.ActionContext;
import com.google.devtools.build.lib.actions.ActionExecutionContext;
+import com.google.devtools.build.lib.actions.ActionExecutionException;
import com.google.devtools.build.lib.actions.ActionInputPrefetcher;
import com.google.devtools.build.lib.actions.ActionKeyContext;
import com.google.devtools.build.lib.actions.Artifact;
@@ -34,6 +35,7 @@
import com.google.devtools.build.lib.actions.SpawnResult;
import com.google.devtools.build.lib.actions.SpawnResult.Status;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
+import com.google.devtools.build.lib.analysis.test.TestActionContext;
import com.google.devtools.build.lib.analysis.test.TestProvider;
import com.google.devtools.build.lib.analysis.test.TestResult;
import com.google.devtools.build.lib.analysis.test.TestRunnerAction;
@@ -153,6 +155,14 @@
return action;
}
+ private List<SpawnResult> execute(
+ TestRunnerAction testRunnerAction,
+ ActionExecutionContext actionExecutionContext,
+ TestActionContext testActionContext)
+ throws ActionExecutionException, InterruptedException {
+ return testRunnerAction.execute(actionExecutionContext, testActionContext).spawnResults();
+ }
+
@Test
public void testRunTestOnce() throws Exception {
ExecutionOptions executionOptions = ExecutionOptions.DEFAULTS;
@@ -185,7 +195,7 @@
// actual StandaloneTestStrategy execution
List<SpawnResult> spawnResults =
- standaloneTestStrategy.exec(testRunnerAction, actionExecutionContext);
+ execute(testRunnerAction, actionExecutionContext, standaloneTestStrategy);
assertThat(spawnResults).contains(expectedSpawnResult);
TestResult result = standaloneTestStrategy.postedResult;
@@ -253,7 +263,7 @@
// actual StandaloneTestStrategy execution
List<SpawnResult> spawnResults =
- standaloneTestStrategy.exec(testRunnerAction, actionExecutionContext);
+ execute(testRunnerAction, actionExecutionContext, standaloneTestStrategy);
assertThat(spawnResults).containsExactly(failSpawnResult, passSpawnResult).inOrder();
@@ -319,7 +329,7 @@
// actual StandaloneTestStrategy execution
List<SpawnResult> spawnResults =
- standaloneTestStrategy.exec(testRunnerAction, actionExecutionContext);
+ execute(testRunnerAction, actionExecutionContext, standaloneTestStrategy);
assertThat(spawnResults).contains(expectedSpawnResult);
@@ -377,7 +387,7 @@
// actual StandaloneTestStrategy execution
List<SpawnResult> spawnResults =
- standaloneTestStrategy.exec(testRunnerAction, actionExecutionContext);
+ execute(testRunnerAction, actionExecutionContext, standaloneTestStrategy);
// check that the rigged SpawnResult was returned
assertThat(spawnResults).contains(expectedSpawnResult);
@@ -460,7 +470,7 @@
// actual StandaloneTestStrategy execution
List<SpawnResult> spawnResults =
- standaloneTestStrategy.exec(testRunnerAction, actionExecutionContext);
+ execute(testRunnerAction, actionExecutionContext, standaloneTestStrategy);
// check that the rigged SpawnResult was returned
assertThat(spawnResults).contains(expectedSpawnResult);
@@ -558,7 +568,7 @@
// actual StandaloneTestStrategy execution
List<SpawnResult> spawnResults =
- standaloneTestStrategy.exec(testRunnerAction, actionExecutionContext);
+ execute(testRunnerAction, actionExecutionContext, standaloneTestStrategy);
// check that the rigged SpawnResult was returned
assertThat(spawnResults).containsExactly(testSpawnResult, xmlGeneratorSpawnResult);
@@ -613,7 +623,7 @@
// actual StandaloneTestStrategy execution
List<SpawnResult> spawnResults =
- standaloneTestStrategy.exec(testRunnerAction, actionExecutionContext);
+ execute(testRunnerAction, actionExecutionContext, standaloneTestStrategy);
// check that the rigged SpawnResult was returned
assertThat(spawnResults).contains(expectedSpawnResult);