diff options
author | 2018-06-15 09:54:05 -0700 | |
---|---|---|
committer | 2018-06-15 09:55:30 -0700 | |
commit | 94f14ad643f5c094cd3b79660f47d80181f80ce0 (patch) | |
tree | b627ac76ff9fc1c30e7ca0897ad5e7a34443911a /src/test | |
parent | 8820d3ae601f229b72c61d2eb601b0e8e9b0111a (diff) |
Support ActionFS opening files with append. Also, fix ActionFS notifying its metadata consumer multiple times per inline output.
RELNOTES: None
PiperOrigin-RevId: 200730252
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/skyframe/ActionFileSystemTest.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ActionFileSystemTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ActionFileSystemTest.java index d7b5e78127..ee90fe69d0 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/ActionFileSystemTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/ActionFileSystemTest.java @@ -23,6 +23,7 @@ import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem; import java.io.OutputStream; +import java.io.PrintStream; import java.nio.charset.StandardCharsets; import org.junit.Before; import org.junit.Test; @@ -64,6 +65,26 @@ public class ActionFileSystemTest { } @Test + public void testAppendLocalFile() throws Exception { + String testData = "abc"; + + Path file = outputPath.getRelative("foo/bar"); + FileSystemUtils.writeContentAsLatin1(file, testData); + assertThat(new String(FileSystemUtils.readContentAsLatin1(file))).isEqualTo(testData); + + try (OutputStream out = file.getOutputStream(true)) { + PrintStream printStream = new PrintStream(out); + printStream.append("defg"); + printStream.flush(); + } + assertThat(new String(FileSystemUtils.readContentAsLatin1(file))).isEqualTo("abcdefg"); + + // Now make sure we can still overwrite the file in non-append mode. + FileSystemUtils.writeContentAsLatin1(file, "cheesy"); + assertThat(new String(FileSystemUtils.readContentAsLatin1(file))).isEqualTo("cheesy"); + } + + @Test public void testFlushedButNotClosedFileWrite() throws Exception { String testData = "abc19"; |