From 4c97d40001493c12c700d0961a74c53a13e37078 Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Mon, 14 Dec 2020 12:27:06 +0100 Subject: [PATCH] Add checks and comments --- scripts/ij.bazelproject | 2 +- .../devtools/build/lib/exec/StandaloneTestStrategy.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/ij.bazelproject b/scripts/ij.bazelproject index d4991199445512..e1c6ef87e1d814 100644 --- a/scripts/ij.bazelproject +++ b/scripts/ij.bazelproject @@ -17,6 +17,6 @@ targets: //src/java_tools/junitrunner/java/com/google/testing/junit/runner:Runner //src/java_tools/junitrunner/javatests/... //src/java_tools/singlejar:SingleJar - //src/test/... + # //src/test/... //src/tools/remote/... //src/tools/starlark/... diff --git a/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java b/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java index f85131a7701019..e382e118e3e21d 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java @@ -401,7 +401,12 @@ private static Spawn createXmlGeneratingSpawn( Long.toString(result.getWallTime().orElse(Duration.ZERO).getSeconds()), Integer.toString(result.exitCode())); ImmutableMap.Builder envBuilder = ImmutableMap.builder(); + // "PATH" and "TEST_BINARY" are also required, they should always be set in testEnv. + Preconditions.checkArgument(testEnv.containsKey("PATH")); + Preconditions.checkArgument(testEnv.containsKey("TEST_BINARY")); envBuilder.putAll(testEnv).put("TEST_NAME", action.getTestName()); + // testEnv only contains TEST_SHARD_INDEX and TEST_TOTAL_SHARDS if the test action is sharded, + // we need to set the default value when the action isn't sharded. if (!action.isSharded()) { envBuilder.put("TEST_SHARD_INDEX", "0"); envBuilder.put("TEST_TOTAL_SHARDS", "0");