diff --git a/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java b/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java index 51c994f62c8385..a488c97fb188e2 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java +++ b/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java @@ -16,6 +16,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.extra.ExtraActionInfo; @@ -549,6 +550,11 @@ public SkylarkDict getEnv() { return SkylarkDict.copyOf(null, env.getFixedEnv().toMap()); } + @Override + public ImmutableMap getExecProperties() { + return getOwner().getExecProperties(); + } + @Override @Nullable public PlatformInfo getExecutionPlatform() { diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionAnalysisMetadata.java b/src/main/java/com/google/devtools/build/lib/actions/ActionAnalysisMetadata.java index 2bf59933c87e54..6074d9d804e9e6 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ActionAnalysisMetadata.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ActionAnalysisMetadata.java @@ -13,6 +13,7 @@ // limitations under the License. package com.google.devtools.build.lib.actions; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.devtools.build.lib.analysis.platform.PlatformInfo; import javax.annotation.Nullable; @@ -250,6 +251,9 @@ default boolean hasLooseHeaders() { return false; } + /** Returns a String to String map containing the execution properties of this action. */ + ImmutableMap getExecProperties(); + /** * Returns the {@link PlatformInfo} platform this action should be executed on. If the execution * platform is {@code null}, then the host platform is assumed. diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionKeyCacher.java b/src/main/java/com/google/devtools/build/lib/actions/ActionKeyCacher.java index abea4970e2e586..f609a2f9b8a012 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ActionKeyCacher.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ActionKeyCacher.java @@ -40,6 +40,8 @@ public final String getKey(ActionKeyContext actionKeyContext) { getExecutionPlatform().addTo(fp); } + fp.addStringMap(getExecProperties()); + // Compute the actual key and store it. cachedKey = fp.hexDigestAndReset(); } catch (CommandLineExpansionException e) { diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java b/src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java index eaad2df80b6cc2..19abab09f14180 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ActionOwner.java @@ -16,6 +16,7 @@ import com.google.auto.value.AutoValue; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.analysis.platform.PlatformInfo; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; @@ -46,6 +47,7 @@ public abstract class ActionOwner { "system", null, null, + ImmutableMap.of(), null); @AutoCodec.Instantiator @@ -58,6 +60,7 @@ public static ActionOwner create( String configurationChecksum, @Nullable BuildConfigurationEvent configuration, @Nullable String additionalProgressInfo, + ImmutableMap execProperties, @Nullable PlatformInfo executionPlatform) { return new AutoValue_ActionOwner( location, @@ -68,6 +71,7 @@ public static ActionOwner create( configuration, targetKind, additionalProgressInfo, + execProperties, executionPlatform); } @@ -111,6 +115,9 @@ public static ActionOwner create( @Nullable abstract String getAdditionalProgressInfo(); + /** Returns a String to String map containing the execution properties of this action. */ + abstract ImmutableMap getExecProperties(); + /** * Returns the {@link PlatformInfo} platform this action should be executed on. If the execution * platform is {@code null}, then the host platform is assumed. diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionTemplate.java b/src/main/java/com/google/devtools/build/lib/actions/ActionTemplate.java index df4e21984fcfa5..f7839418ef767c 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ActionTemplate.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ActionTemplate.java @@ -13,6 +13,7 @@ // limitations under the License. package com.google.devtools.build.lib.actions; +import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.actions.ActionLookupValue.ActionLookupKey; import com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact; import com.google.devtools.build.lib.analysis.platform.PlatformInfo; @@ -88,6 +89,11 @@ Iterable generateActionForInputArtifacts( /** Returns the output TreeArtifact. */ Artifact getOutputTreeArtifact(); + @Override + default ImmutableMap getExecProperties() { + return ImmutableMap.of(); + } + @Override @Nullable default PlatformInfo getExecutionPlatform() { diff --git a/src/main/java/com/google/devtools/build/lib/actions/BaseSpawn.java b/src/main/java/com/google/devtools/build/lib/actions/BaseSpawn.java index dcba4032547055..f2c61d9038daae 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/BaseSpawn.java +++ b/src/main/java/com/google/devtools/build/lib/actions/BaseSpawn.java @@ -150,6 +150,11 @@ public String getMnemonic() { return action.getMnemonic(); } + @Override + public ImmutableMap getCombinedExecProperties() { + return action.getOwner().getExecProperties(); + } + @Override @Nullable public PlatformInfo getExecutionPlatform() { diff --git a/src/main/java/com/google/devtools/build/lib/actions/DelegateSpawn.java b/src/main/java/com/google/devtools/build/lib/actions/DelegateSpawn.java index f4ae81b4ebaee7..ca45bfb93618b2 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/DelegateSpawn.java +++ b/src/main/java/com/google/devtools/build/lib/actions/DelegateSpawn.java @@ -87,6 +87,11 @@ public String getMnemonic() { return spawn.getMnemonic(); } + @Override + public ImmutableMap getCombinedExecProperties() { + return spawn.getCombinedExecProperties(); + } + @Override @Nullable public PlatformInfo getExecutionPlatform() { diff --git a/src/main/java/com/google/devtools/build/lib/actions/SimpleSpawn.java b/src/main/java/com/google/devtools/build/lib/actions/SimpleSpawn.java index a9b6e547153ddc..536cb311022cbf 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/SimpleSpawn.java +++ b/src/main/java/com/google/devtools/build/lib/actions/SimpleSpawn.java @@ -139,6 +139,11 @@ public String getMnemonic() { return owner.getMnemonic(); } + @Override + public ImmutableMap getCombinedExecProperties() { + return owner.getExecProperties(); + } + @Override @Nullable public PlatformInfo getExecutionPlatform() { diff --git a/src/main/java/com/google/devtools/build/lib/actions/Spawn.java b/src/main/java/com/google/devtools/build/lib/actions/Spawn.java index 3f7aa20a67cba7..273a7b3c708c20 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/Spawn.java +++ b/src/main/java/com/google/devtools/build/lib/actions/Spawn.java @@ -111,6 +111,14 @@ public interface Spawn { */ String getMnemonic(); + /** + * Returns execution properties related to this spawn. + * + *

Note that this includes data from the execution platform's exec_properties as well as + * target-level exec_properties. TODO(agoulti): implement target-level exec_properties. + */ + ImmutableMap getCombinedExecProperties(); + @Nullable PlatformInfo getExecutionPlatform(); } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java index e8a820c0cb072e..b11ba26463b827 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java @@ -514,6 +514,14 @@ public static ActionOwner createActionOwner( ImmutableList aspectDescriptors, BuildConfiguration configuration, @Nullable PlatformInfo executionPlatform) { + ImmutableMap execProperties; + if (executionPlatform != null) { + execProperties = executionPlatform.execProperties(); + } else { + execProperties = ImmutableMap.of(); + } + // TODO(agoulti): Insert logic to include per-target execution properties + return ActionOwner.create( rule.getLabel(), aspectDescriptors, @@ -523,6 +531,7 @@ public static ActionOwner createActionOwner( configuration.checksum(), configuration.toBuildEvent(), configuration.isHostConfiguration() ? HOST_CONFIGURATION_PROGRESS_TAG : null, + execProperties, executionPlatform); } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/platform/PlatformUtils.java b/src/main/java/com/google/devtools/build/lib/analysis/platform/PlatformUtils.java index 131bdfbf5a2d13..637b60795d44a1 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/platform/PlatformUtils.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/platform/PlatformUtils.java @@ -19,6 +19,7 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.Ordering; +import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.UserExecException; import com.google.devtools.build.lib.remote.options.RemoteOptions; import com.google.protobuf.TextFormat; @@ -33,35 +34,36 @@ public final class PlatformUtils { @Nullable - public static Platform getPlatformProto( - @Nullable PlatformInfo executionPlatform, @Nullable RemoteOptions remoteOptions) + public static Platform getPlatformProto(Spawn spawn, @Nullable RemoteOptions remoteOptions) throws UserExecException { SortedMap defaultExecProperties = remoteOptions != null ? remoteOptions.getRemoteDefaultExecProperties() : ImmutableSortedMap.of(); - if (executionPlatform == null && defaultExecProperties.isEmpty()) { + if (spawn.getExecutionPlatform() == null + && spawn.getCombinedExecProperties().isEmpty() + && defaultExecProperties.isEmpty()) { return null; } Platform.Builder platformBuilder = Platform.newBuilder(); - if (executionPlatform != null && !executionPlatform.execProperties().isEmpty()) { - for (Map.Entry entry : executionPlatform.execProperties().entrySet()) { + if (!spawn.getCombinedExecProperties().isEmpty()) { + for (Map.Entry entry : spawn.getCombinedExecProperties().entrySet()) { platformBuilder.addPropertiesBuilder().setName(entry.getKey()).setValue(entry.getValue()); } - } else if (executionPlatform != null - && !Strings.isNullOrEmpty(executionPlatform.remoteExecutionProperties())) { + } else if (spawn.getExecutionPlatform() != null + && !Strings.isNullOrEmpty(spawn.getExecutionPlatform().remoteExecutionProperties())) { // Try and get the platform info from the execution properties. try { TextFormat.getParser() - .merge(executionPlatform.remoteExecutionProperties(), platformBuilder); + .merge(spawn.getExecutionPlatform().remoteExecutionProperties(), platformBuilder); } catch (ParseException e) { throw new UserExecException( String.format( "Failed to parse remote_execution_properties from platform %s", - executionPlatform.label()), + spawn.getExecutionPlatform().label()), e); } } else { diff --git a/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java b/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java index 2e13cce18a6b8f..fa6bb5edc2874d 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java +++ b/src/main/java/com/google/devtools/build/lib/exec/SpawnLogContext.java @@ -129,8 +129,7 @@ public void logSpawn( } builder.setRemotable(Spawns.mayBeExecutedRemotely(spawn)); - Platform execPlatform = - PlatformUtils.getPlatformProto(spawn.getExecutionPlatform(), remoteOptions); + Platform execPlatform = PlatformUtils.getPlatformProto(spawn, remoteOptions); if (execPlatform != null) { builder.setPlatform(buildPlatform(execPlatform)); } diff --git a/src/main/java/com/google/devtools/build/lib/includescanning/SpawnIncludeScanner.java b/src/main/java/com/google/devtools/build/lib/includescanning/SpawnIncludeScanner.java index def654bd14434f..06569c82ac7d77 100644 --- a/src/main/java/com/google/devtools/build/lib/includescanning/SpawnIncludeScanner.java +++ b/src/main/java/com/google/devtools/build/lib/includescanning/SpawnIncludeScanner.java @@ -194,6 +194,11 @@ public RunfilesSupplier getRunfilesSupplier() { throw new UnsupportedOperationException(); } + @Override + public ImmutableMap getExecProperties() { + return actionExecutionMetadata.getExecProperties(); + } + @Override @Nullable public PlatformInfo getExecutionPlatform() { diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java index 5faa969914cae0..d24d5d5383cd79 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnCache.java @@ -132,7 +132,7 @@ public CacheHandle lookup(Spawn spawn, SpawnExecutionContext context) Digest merkleTreeRoot = merkleTree.getRootDigest(); // Get the remote platform properties. - Platform platform = PlatformUtils.getPlatformProto(spawn.getExecutionPlatform(), options); + Platform platform = PlatformUtils.getPlatformProto(spawn, options); Command command = RemoteSpawnRunner.buildCommand( diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java index 8dfd5a1ec4f449..56c2d8407f9448 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnRunner.java @@ -169,7 +169,7 @@ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context) maybeWriteParamFilesLocally(spawn); // Get the remote platform properties. - Platform platform = PlatformUtils.getPlatformProto(spawn.getExecutionPlatform(), remoteOptions); + Platform platform = PlatformUtils.getPlatformProto(spawn, remoteOptions); Command command = buildCommand( diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/DockerSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/DockerSandboxedSpawnRunner.java index 773c17eb3b1513..b8c4e18332ff08 100644 --- a/src/main/java/com/google/devtools/build/lib/sandbox/DockerSandboxedSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/sandbox/DockerSandboxedSpawnRunner.java @@ -377,8 +377,7 @@ private String executeCommand(List cmdLine, InputStream stdIn) throws Us private Optional dockerContainerFromSpawn(Spawn spawn) throws ExecException { Platform platform = - PlatformUtils.getPlatformProto( - spawn.getExecutionPlatform(), cmdEnv.getOptions().getOptions(RemoteOptions.class)); + PlatformUtils.getPlatformProto(spawn, cmdEnv.getOptions().getOptions(RemoteOptions.class)); if (platform != null) { try { diff --git a/src/test/java/com/google/devtools/build/lib/actions/ResourceManagerTest.java b/src/test/java/com/google/devtools/build/lib/actions/ResourceManagerTest.java index 876a649bbf4de0..f919c28f786fa2 100644 --- a/src/test/java/com/google/devtools/build/lib/actions/ResourceManagerTest.java +++ b/src/test/java/com/google/devtools/build/lib/actions/ResourceManagerTest.java @@ -17,6 +17,7 @@ import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.devtools.build.lib.actions.ResourceManager.ResourceHandle; import com.google.devtools.build.lib.analysis.platform.PlatformInfo; @@ -547,6 +548,11 @@ public MiddlemanType getActionType() { throw new IllegalStateException(); } + @Override + public ImmutableMap getExecProperties() { + throw new IllegalStateException(); + } + @Nullable @Override public PlatformInfo getExecutionPlatform() { diff --git a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java index 4abf3d37e3083e..1b6312d5f0ffc6 100644 --- a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java +++ b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java @@ -346,6 +346,7 @@ public Label getLabel() { "dummy-configuration", null, null, + ImmutableMap.of(), null); @AutoCodec diff --git a/src/test/java/com/google/devtools/build/lib/analysis/platform/BUILD b/src/test/java/com/google/devtools/build/lib/analysis/platform/BUILD index cc8b443e811c0f..088bf87c7af1db 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/platform/BUILD +++ b/src/test/java/com/google/devtools/build/lib/analysis/platform/BUILD @@ -23,6 +23,7 @@ java_test( "//src/main/java/com/google/devtools/build/lib:packages-internal", "//src/main/java/com/google/devtools/build/lib:syntax", "//src/main/java/com/google/devtools/build/lib:util", + "//src/main/java/com/google/devtools/build/lib/actions", "//src/main/java/com/google/devtools/build/lib/analysis/platform", "//src/main/java/com/google/devtools/build/lib/analysis/platform:platform_utils", "//src/main/java/com/google/devtools/build/lib/analysis/platform:utils", diff --git a/src/test/java/com/google/devtools/build/lib/analysis/platform/PlatformUtilsTest.java b/src/test/java/com/google/devtools/build/lib/analysis/platform/PlatformUtilsTest.java index d6c4a7140bbff9..f1048b96598cc0 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/platform/PlatformUtilsTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/platform/PlatformUtilsTest.java @@ -18,6 +18,8 @@ import build.bazel.remote.execution.v2.Platform; import com.google.common.collect.ImmutableMap; +import com.google.devtools.build.lib.actions.Spawn; +import com.google.devtools.build.lib.exec.util.SpawnBuilder; import com.google.devtools.build.lib.remote.options.RemoteOptions; import com.google.devtools.common.options.Options; import org.junit.Test; @@ -27,23 +29,39 @@ /** Tests for {@link PlatformUtils } */ @RunWith(JUnit4.class) public final class PlatformUtilsTest { + private static String platformOptionsString() { + return String.join( + "\n", + "properties: {", + " name: \"b\"", + " value: \"2\"", + "}", + "properties: {", + " name: \"a\"", + " value: \"1\"", + "}"); + } + private static RemoteOptions remoteOptions() { RemoteOptions remoteOptions = Options.getDefaults(RemoteOptions.class); - remoteOptions.remoteDefaultPlatformProperties = - String.join( - "\n", - "properties: {", - " name: \"b\"", - " value: \"2\"", - "}", - "properties: {", - " name: \"a\"", - " value: \"1\"", - "}"); + remoteOptions.remoteDefaultPlatformProperties = platformOptionsString(); return remoteOptions; } + @Test + public void testParsePlatformLegacyOptions() throws Exception { + Platform expected = + Platform.newBuilder() + .addProperties(Platform.Property.newBuilder().setName("a").setValue("1")) + .addProperties(Platform.Property.newBuilder().setName("b").setValue("2")) + .build(); + PlatformInfo platform = + PlatformInfo.builder().setRemoteExecutionProperties(platformOptionsString()).build(); + Spawn s = new SpawnBuilder("dummy").withPlatform(platform).build(); + assertThat(PlatformUtils.getPlatformProto(s, null)).isEqualTo(expected); + } + @Test public void testParsePlatformSortsProperties() throws Exception { Platform expected = @@ -51,19 +69,21 @@ public void testParsePlatformSortsProperties() throws Exception { .addProperties(Platform.Property.newBuilder().setName("a").setValue("1")) .addProperties(Platform.Property.newBuilder().setName("b").setValue("2")) .build(); - assertThat(PlatformUtils.getPlatformProto(null, remoteOptions())).isEqualTo(expected); + Spawn s = new SpawnBuilder("dummy").build(); + assertThat(PlatformUtils.getPlatformProto(s, remoteOptions())).isEqualTo(expected); } @Test public void testParsePlatformHandlesNull() throws Exception { - assertThat(PlatformUtils.getPlatformProto(null, null)).isEqualTo(null); + Spawn s = new SpawnBuilder("dummy").build(); + assertThat(PlatformUtils.getPlatformProto(s, null)).isEqualTo(null); } @Test public void testParsePlatformSortsProperties_ExecProperties() throws Exception { // execProperties are chosen even if there are remoteOptions ImmutableMap map = ImmutableMap.of("aa", "99", "zz", "66", "dd", "11"); - PlatformInfo platformInfo = PlatformInfo.builder().setExecProperties(map).build(); + Spawn s = new SpawnBuilder("dummy").withExecProperties(map).build(); Platform expected = Platform.newBuilder() @@ -72,6 +92,6 @@ public void testParsePlatformSortsProperties_ExecProperties() throws Exception { .addProperties(Platform.Property.newBuilder().setName("zz").setValue("66")) .build(); // execProperties are sorted by key - assertThat(PlatformUtils.getPlatformProto(platformInfo, remoteOptions())).isEqualTo(expected); + assertThat(PlatformUtils.getPlatformProto(s, remoteOptions())).isEqualTo(expected); } } diff --git a/src/test/java/com/google/devtools/build/lib/exec/util/FakeOwner.java b/src/test/java/com/google/devtools/build/lib/exec/util/FakeOwner.java index b501cb2b5f6f1e..4a20ae37f2b47d 100644 --- a/src/test/java/com/google/devtools/build/lib/exec/util/FakeOwner.java +++ b/src/test/java/com/google/devtools/build/lib/exec/util/FakeOwner.java @@ -14,8 +14,10 @@ package com.google.devtools.build.lib.exec.util; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.devtools.build.lib.actions.ActionAnalysisMetadata; +import com.google.devtools.build.lib.actions.ActionAnalysisMetadata.MiddlemanType; import com.google.devtools.build.lib.actions.ActionExecutionContext; import com.google.devtools.build.lib.actions.ActionExecutionMetadata; import com.google.devtools.build.lib.actions.ActionKeyContext; @@ -35,16 +37,27 @@ public final class FakeOwner implements ActionExecutionMetadata { private final String progressMessage; @Nullable private final String ownerLabel; @Nullable private final PlatformInfo platform; + ImmutableMap execProperties; public FakeOwner( String mnemonic, String progressMessage, @Nullable String ownerLabel, - @Nullable PlatformInfo platform) { + @Nullable PlatformInfo platform, + ImmutableMap execProperties) { this.mnemonic = mnemonic; this.progressMessage = progressMessage; this.ownerLabel = ownerLabel; this.platform = platform; + this.execProperties = execProperties; + } + + public FakeOwner( + String mnemonic, + String progressMessage, + @Nullable String ownerLabel, + @Nullable PlatformInfo platform) { + this(mnemonic, progressMessage, ownerLabel, platform, ImmutableMap.of()); } public FakeOwner(String mnemonic, String progressMessage, @Nullable String ownerLabel) { @@ -66,6 +79,7 @@ public ActionOwner getOwner() { "configurationChecksum", /* configuration=*/ null, "additionalProgressInfo", + /* execProperties=*/ ImmutableMap.of(), null); } @@ -175,6 +189,11 @@ public boolean shouldReportPathPrefixConflict(ActionAnalysisMetadata action) { throw new UnsupportedOperationException(); } + @Override + public ImmutableMap getExecProperties() { + return execProperties; + } + @Nullable @Override public PlatformInfo getExecutionPlatform() { diff --git a/src/test/java/com/google/devtools/build/lib/exec/util/SpawnBuilder.java b/src/test/java/com/google/devtools/build/lib/exec/util/SpawnBuilder.java index 1a94ed67fad2d9..88ddf2cf56d027 100644 --- a/src/test/java/com/google/devtools/build/lib/exec/util/SpawnBuilder.java +++ b/src/test/java/com/google/devtools/build/lib/exec/util/SpawnBuilder.java @@ -44,6 +44,7 @@ public final class SpawnBuilder { private final List args; private final Map environment = new HashMap<>(); private final Map executionInfo = new HashMap<>(); + private ImmutableMap execProperties = ImmutableMap.of(); private final List inputs = new ArrayList<>(); private final List outputs = new ArrayList<>(); private final Map> filesetMappings = @@ -56,7 +57,8 @@ public SpawnBuilder(String... args) { } public Spawn build() { - ActionExecutionMetadata owner = new FakeOwner(mnemonic, progressMessage, ownerLabel, platform); + ActionExecutionMetadata owner = + new FakeOwner(mnemonic, progressMessage, ownerLabel, platform, execProperties); return new SimpleSpawn( owner, ImmutableList.copyOf(args), @@ -100,6 +102,11 @@ public SpawnBuilder withExecutionInfo(String key, String value) { return this; } + public SpawnBuilder withExecProperties(ImmutableMap execProperties) { + this.execProperties = execProperties; + return this; + } + public SpawnBuilder withInput(ActionInput input) { this.inputs.add(input); return this; diff --git a/src/test/java/com/google/devtools/build/lib/runtime/UiStateTrackerTest.java b/src/test/java/com/google/devtools/build/lib/runtime/UiStateTrackerTest.java index e94111103bef9e..fb052c6dbe46e1 100644 --- a/src/test/java/com/google/devtools/build/lib/runtime/UiStateTrackerTest.java +++ b/src/test/java/com/google/devtools/build/lib/runtime/UiStateTrackerTest.java @@ -530,6 +530,7 @@ public void testSensibleShortening() throws Exception { "fedcba", null, null, + ImmutableMap.of(), null); when(action.getOwner()).thenReturn(owner); @@ -956,6 +957,7 @@ public void testAggregation() throws Exception { "abcdef", null, null, + ImmutableMap.of(), null); Label labelBarTest = Label.parseAbsolute("//baz:bartest", ImmutableMap.of()); @@ -974,6 +976,7 @@ public void testAggregation() throws Exception { "fedcba", null, null, + ImmutableMap.of(), null); stateTracker.testFilteringComplete(filteringComplete);