From 80d79a861a9e06792483870bef93e820ed484252 Mon Sep 17 00:00:00 2001 From: Jakob Buchgraber Date: Thu, 21 Mar 2019 15:41:38 +0100 Subject: [PATCH] Pass execution info to xml generating spawn. Fixes #7794 Change [1] splits test execution into two spawns. The first spawn runs the test and the second spawn generates the test.xml from the test.log file. This change makes it so that the test.xml-generating spawn also inherits the execution info from the test target. In particular, if a test target is tagged with "no-remote" then the test.xml-generating spawn will also be tagged. [1] https://github.com/bazelbuild/bazel/commit/0858ae1f6eb890c1e203a2aa21130ba34ca36a27 --- .../devtools/build/lib/exec/StandaloneTestStrategy.java | 4 +++- .../devtools/build/lib/exec/StandaloneTestStrategyTest.java | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) 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 43e72787d289c8..cc483672c9d046 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 @@ -465,7 +465,9 @@ private Spawn createXmlGeneratingSpawn(TestRunnerAction action, SpawnResult resu "TEST_TOTAL_SHARDS", Integer.toString(action.getExecutionSettings().getTotalShards()), "TEST_NAME", action.getTestName(), "TEST_BINARY", testBinaryName), - ImmutableMap.of(), + // Pass the execution info of the action which is identical to the supported tags set on the + // test target. In particular, this does not set the test timeout on the spawn. + ImmutableMap.copyOf(action.getExecutionInfo()), null, ImmutableMap.of(), /*inputs=*/ ImmutableList.of(action.getTestXmlGeneratorScript(), action.getTestLog()), 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 771958614fb948..219d89e041e650 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 @@ -519,6 +519,7 @@ public void testThatTestLogAndOutputAreReturnedWithSplitXmlGeneration() throws E " name = \"failing_test\",", " size = \"small\",", " srcs = [\"failing_test.sh\"],", + " tags = [\"local\"],", ")"); TestRunnerAction testRunnerAction = getTestAction("//standalone:failing_test"); @@ -538,6 +539,8 @@ public void testThatTestLogAndOutputAreReturnedWithSplitXmlGeneration() throws E .thenAnswer( (invocation) -> { Spawn spawn = invocation.getArgument(0); + // Test that both spawns have the local tag attached as a execution info + assertThat(spawn.getExecutionInfo()).containsKey("local"); ActionExecutionContext context = invocation.getArgument(1); FileOutErr outErr = context.getFileOutErr(); called.add(outErr);