diff options
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java index f9ff08e22d..ea00194bab 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java @@ -681,6 +681,24 @@ public class PackageFunctionTest extends BuildViewTestCase { assertThat(errorInfo.getException()).hasCauseThat().isSameAs(exn); } + @Test + public void testPackageLoadingErrorOnIOExceptionReadingBzlFile() throws Exception { + scratch.file("foo/BUILD", "load('//foo:bzl.bzl', 'x')"); + Path fooBzlFilePath = scratch.file("foo/bzl.bzl"); + IOException exn = new IOException("nope"); + fs.throwExceptionOnGetInputStream(fooBzlFilePath, exn); + + SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo")); + EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate( + getSkyframeExecutor(), skyKey, /*keepGoing=*/false, reporter); + assertThat(result.hasError()).isTrue(); + ErrorInfo errorInfo = result.getError(skyKey); + String errorMessage = errorInfo.getException().getMessage(); + assertThat(errorMessage).contains("nope"); + assertThat(errorInfo.getException()).isInstanceOf(NoSuchPackageException.class); + assertThat(errorInfo.getException()).hasCauseThat().isSameAs(exn); + } + private static class CustomInMemoryFs extends InMemoryFileSystem { private abstract static class FileStatusOrException { abstract FileStatus get() throws IOException; |