If globbing throws an IOException, fail to construct the package instead of constructing the package with an error. Prior to this change, if a Package.Builder object was constructed, it was guaranteed that a Package (possibly with errors) would be created. This is no longer true: if an IOException is set on the Package.Builder object, it will throw a NoSuchPackageException during #build(). PiperOrigin-RevId: 161832111
diff --git a/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java b/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java index 3f72ce2..afa6a89 100644 --- a/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java +++ b/src/test/java/com/google/devtools/build/lib/pkgcache/IncrementalLoadingTest.java
@@ -338,15 +338,15 @@ tester.addFile("e/data.txt"); throwOnReaddir = parentDir; tester.sync(); - Target target = tester.getTarget("//e:e"); - assertThat(((Rule) target).containsErrors()).isTrue(); - GlobList<?> globList = (GlobList<?>) ((Rule) target).getAttributeContainer().getAttr("data"); - assertThat(globList).isEmpty(); + try { + tester.getTarget("//e:e"); + } catch (NoSuchPackageException expected) { + } throwOnReaddir = null; tester.sync(); - target = tester.getTarget("//e:e"); + Target target = tester.getTarget("//e:e"); assertThat(((Rule) target).containsErrors()).isFalse(); - globList = (GlobList<?>) ((Rule) target).getAttributeContainer().getAttr("data"); + GlobList<?> globList = (GlobList<?>) ((Rule) target).getAttributeContainer().getAttr("data"); assertThat(globList).containsExactly(Label.parseAbsolute("//e:data.txt")); }