Fix configuration error handling for the interleaved case. In the interleaved case, loading errors can occur during configuration creation and we need to correctly report such errors in that case. -- MOS_MIGRATED_REVID=113826273
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java b/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java index ac289bb..1e9e882 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java
@@ -1011,6 +1011,27 @@ .contains("execution phase succeeded, but there were loading phase errors"); } + @Test + public void testMissingLabelInConfiguration() throws Exception { + scratch.file("nobuild/BUILD", + "cc_library(name= 'lib')"); + useConfiguration("--experimental_action_listener=//nobuild:bar"); + reporter.removeHandler(failFastHandler); + String begin = String.format( + "Failed to load required %s target: '%s'", "action_listener", "//nobuild:bar"); + try { + update(defaultFlags().with(Flag.KEEP_GOING), "//nobuild:lib"); + fail(); + } catch (InvalidConfigurationException e) { + // Interleaved loading and analysis - loading errors are found during configuration creation. + assertThat(e.getMessage()).startsWith(begin); + } catch (LoadingFailedException e) { + assertThat(e.getMessage()).startsWith(begin); + } + assertContainsEventWithFrequency( + "no such target '//nobuild:bar': target 'bar' not declared in package 'nobuild'", 1); + } + /** Runs the same test with the reduced loading phase. */ @TestSpec(size = Suite.SMALL_TESTS) @RunWith(JUnit4.class)