Provides a clearer message when target analysis fails because its dynamic
config is missing required fragments.

Before this change, Bazel crashes with the mysterious error: "Fragment
foo can't load missing options BarOptions" with no details on which target or dep
needed Foo. So figuring out the source of the error is painful.

With this change, we instead get:

  //foo:foo: dependency //bar:bar from attribute "deps" is missing required config fragments: JavaConfiguration

--
MOS_MIGRATED_REVID=129143764
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 3efe26b..8d45c93 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
@@ -1230,6 +1230,28 @@
         ruleClassProvider.getUniversalFragment());
   }
 
+  @Test
+  public void errorOnMissingDepFragments() throws Exception {
+    scratch.file("foo/BUILD",
+        "cc_library(",
+        "    name = 'ccbin', ",
+        "    srcs = ['c.cc'],",
+        "    data = [':javalib'])",
+        "java_library(",
+        "    name = 'javalib',",
+        "    srcs = ['javalib.java'])");
+    useConfiguration("--experimental_dynamic_configs", "--experimental_disable_jvm");
+    reporter.removeHandler(failFastHandler);
+    try {
+      update("//foo:ccbin");
+      fail();
+    } catch (ViewCreationFailedException e) {
+      // Expected.
+    }
+    assertContainsEvent("//foo:ccbin: dependency //foo:javalib from attribute \"data\" is missing "
+        + "required config fragments: Jvm");
+  }
+
   /** Runs the same test with the reduced loading phase. */
   @TestSpec(size = Suite.SMALL_TESTS)
   @RunWith(JUnit4.class)