diff options
author | 2017-07-20 18:07:20 +0200 | |
---|---|---|
committer | 2017-07-21 09:12:26 +0200 | |
commit | 513288b97611f4ba1a2627fd3a54fbdf64ecbe13 (patch) | |
tree | 2eeccbecb3328d3f7dfaceb4d4d224c0daaf797c /src/test/java/com/google/devtools/build/lib/skyframe | |
parent | 94153a6b0ffdd019866c26130d4ec845f730b29e (diff) |
Tolerate injected nodes having deps.
We don't check explicitly that these are the only two ways, but this can happen if the error transience node is a dep of a node that's being injected, or if an injected node is an "external" file that needs to depend on an external package.
The first possibility can happen if there was an IOException reading the node on the previous build.
We handle the situation by just dirtying the node, not injecting it. Actual evaluation can handle the re-stat.
PiperOrigin-RevId: 162622092
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/skyframe')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java index 50b98a6967..4c349f831f 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java @@ -44,19 +44,21 @@ import com.google.devtools.build.lib.testutil.ManualClock; import com.google.devtools.build.lib.testutil.TestConstants; import com.google.devtools.build.lib.testutil.TestRuleClassProvider; import com.google.devtools.build.lib.testutil.TestUtils; +import com.google.devtools.build.lib.util.BlazeClock; import com.google.devtools.build.lib.util.Pair; import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor; import com.google.devtools.build.lib.vfs.FileStatus; import com.google.devtools.build.lib.vfs.FileSystem; -import com.google.devtools.build.lib.vfs.FileSystem.HashFunction; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.lib.vfs.RootedPath; import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem; import com.google.devtools.build.lib.vfs.util.FileSystems; +import com.google.devtools.build.skyframe.BuildDriver; import com.google.devtools.build.skyframe.ErrorInfo; +import com.google.devtools.build.skyframe.ErrorInfoSubject; import com.google.devtools.build.skyframe.EvaluationResult; import com.google.devtools.build.skyframe.InMemoryMemoizingEvaluator; import com.google.devtools.build.skyframe.MemoizingEvaluator; @@ -1272,6 +1274,41 @@ public class FileFunctionTest { assertThat(valueForPath(child).exists()).isFalse(); } + @Test + public void testInjectionOverIOException() throws Exception { + Path foo = file("foo"); + SkyKey fooKey = skyKey("foo"); + fs.stubStatError(foo, new IOException("bork")); + BuildDriver driver = makeDriver(); + EvaluationResult<FileValue> result = + driver.evaluate( + ImmutableList.of(fooKey), + /*keepGoing=*/ true, + /*numThreads=*/ 1, + NullEventHandler.INSTANCE); + ErrorInfoSubject errorInfoSubject = assertThatEvaluationResult(result) + .hasErrorEntryForKeyThat(fooKey); + errorInfoSubject.isTransient(); + errorInfoSubject + .hasExceptionThat() + .hasMessageThat() + .isEqualTo("bork"); + fs.stubbedStatErrors.remove(foo); + differencer.inject( + fileStateSkyKey("foo"), + FileStateValue.create( + RootedPath.toRootedPath(pkgRoot, foo), + new TimestampGranularityMonitor(BlazeClock.instance()))); + result = + driver.evaluate( + ImmutableList.of(fooKey), + /*keepGoing=*/ true, + /*numThreads=*/ 1, + NullEventHandler.INSTANCE); + assertThatEvaluationResult(result).hasNoError(); + assertThat(result.get(fooKey).exists()).isTrue(); + } + private void checkRealPath(String pathString) throws Exception { Path realPath = pkgRoot.getRelative(pathString).resolveSymbolicLinks(); assertRealPath(pathString, realPath.relativeTo(pkgRoot).toString()); |