diff --git a/src/main/java/com/google/devtools/build/lib/analysis/producers/PlatformFlagsProducer.java b/src/main/java/com/google/devtools/build/lib/analysis/producers/PlatformFlagsProducer.java index d450788dd1d276..48c4dc52166286 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/producers/PlatformFlagsProducer.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/producers/PlatformFlagsProducer.java @@ -31,11 +31,11 @@ public class PlatformFlagsProducer implements StateMachine, PlatformInfoProducer.ResultSink { interface ResultSink { - void acceptPlatformFlags(NativeAndStarlarkFlags flags); + void acceptPlatformFlags(Label platform, NativeAndStarlarkFlags flags); - void acceptPlatformFlagsError(InvalidPlatformException error); + void acceptPlatformFlagsError(Label platform, InvalidPlatformException error); - void acceptPlatformFlagsError(OptionsParsingException error); + void acceptPlatformFlagsError(Label platform, OptionsParsingException error); } // -------------------- Input -------------------- @@ -85,7 +85,7 @@ public void acceptPlatformInfo(PlatformInfo info) { @Override public void acceptPlatformInfoError(InvalidPlatformException error) { - sink.acceptPlatformFlagsError(error); + sink.acceptPlatformFlagsError(this.platformLabel, error); } private StateMachine parsePlatformFlags(Tasks tasks) { @@ -113,7 +113,7 @@ private void acceptParsedFlagsValue( return; } if (exception != null) { - sink.acceptPlatformFlagsError(exception); + sink.acceptPlatformFlagsError(this.platformLabel, exception); return; } throw new IllegalStateException("Both value and exception are null"); @@ -123,7 +123,7 @@ private StateMachine handleParsedFlags(Tasks tasks) { if (this.parsedFlags == null) { return DONE; // There was an error. } - sink.acceptPlatformFlags(this.parsedFlags); + sink.acceptPlatformFlags(this.platformLabel, this.parsedFlags); return this.runAfter; } } diff --git a/src/test/java/com/google/devtools/build/lib/analysis/producers/PlatformFlagsProducerTest.java b/src/test/java/com/google/devtools/build/lib/analysis/producers/PlatformFlagsProducerTest.java index 27a2069f63c6fa..6746dcd8904248 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/producers/PlatformFlagsProducerTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/producers/PlatformFlagsProducerTest.java @@ -111,7 +111,7 @@ public void starlarkFlag_invalid() throws Exception { private NativeAndStarlarkFlags fetch(Label platformLabel) throws InvalidPlatformException, InterruptedException, OptionsParsingException { - PlatformFlagsSink sink = new PlatformFlagsSink(); + PlatformFlagsSink sink = new PlatformFlagsSink(platformLabel); PlatformFlagsProducer producer = new PlatformFlagsProducer(platformLabel, sink, StateMachine.DONE); var unused = executeProducer(producer); @@ -120,22 +120,30 @@ private NativeAndStarlarkFlags fetch(Label platformLabel) /** Receiver for platform info from {@link PlatformFlagsProducer}. */ private static class PlatformFlagsSink implements PlatformFlagsProducer.ResultSink { + private final Label expectedPlatform; @Nullable private NativeAndStarlarkFlags parsedFlags = null; @Nullable private InvalidPlatformException invalidPlatformException = null; @Nullable private OptionsParsingException optionParsingException = null; + private PlatformFlagsSink(Label expectedPlatform) { + this.expectedPlatform = expectedPlatform; + } + @Override - public void acceptPlatformFlags(NativeAndStarlarkFlags parsedFlags) { + public void acceptPlatformFlags(Label platform, NativeAndStarlarkFlags parsedFlags) { + assertThat(platform).isEqualTo(this.expectedPlatform); this.parsedFlags = parsedFlags; } @Override - public void acceptPlatformFlagsError(InvalidPlatformException error) { + public void acceptPlatformFlagsError(Label platform, InvalidPlatformException error) { + assertThat(platform).isEqualTo(this.expectedPlatform); this.invalidPlatformException = error; } @Override - public void acceptPlatformFlagsError(OptionsParsingException error) { + public void acceptPlatformFlagsError(Label platform, OptionsParsingException error) { + assertThat(platform).isEqualTo(this.expectedPlatform); this.optionParsingException = error; }