diff options
author | Chris Parsons <cparsons@google.com> | 2016-07-26 17:52:37 +0000 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2016-07-27 11:15:10 +0000 |
commit | cb5aa0067d5775c5ada1b751adc502ad2375352b (patch) | |
tree | f529c5cbd41099f2cb39743fd30e5c89a602060f /src/test/java/com/google/devtools | |
parent | a1a13aefe738cfa3991ae0ba89fe4488b78a1342 (diff) |
Fixed JavaIoFileSystem.setLastModifiedTime to actually match its documented behavior (passing -1 modified time should use system time).
--
MOS_MIGRATED_REVID=128489592
Diffstat (limited to 'src/test/java/com/google/devtools')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/vfs/JavaIoFileSystemTest.java | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/JavaIoFileSystemTest.java b/src/test/java/com/google/devtools/build/lib/vfs/JavaIoFileSystemTest.java index 3251b09bee..efbd5b0dbf 100644 --- a/src/test/java/com/google/devtools/build/lib/vfs/JavaIoFileSystemTest.java +++ b/src/test/java/com/google/devtools/build/lib/vfs/JavaIoFileSystemTest.java @@ -13,6 +13,10 @@ // limitations under the License. package com.google.devtools.build.lib.vfs; +import static org.junit.Assert.assertEquals; + +import com.google.devtools.build.lib.testutil.ManualClock; + import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -25,16 +29,34 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public class JavaIoFileSystemTest extends SymlinkAwareFileSystemTest { + private ManualClock clock; + @Override public FileSystem getFreshFileSystem() { - return new JavaIoFileSystem(); + clock = new ManualClock(); + return new JavaIoFileSystem(clock); } - // The tests are just inherited from the FileSystemTest + // Tests are inherited from the FileSystemTest // JavaIoFileSystem incorrectly throws a FileNotFoundException for all IO errors. This means that // statIfFound incorrectly suppresses those errors. @Override @Test public void testBadPermissionsThrowsExceptionOnStatIfFound() {} + + @Test + public void testSetLastModifiedTime() throws Exception { + Path file = xEmptyDirectory.getChild("new-file"); + FileSystemUtils.createEmptyFile(file); + + file.setLastModifiedTime(1000L); + assertEquals(1000L, file.getLastModifiedTime()); + file.setLastModifiedTime(0L); + assertEquals(0L, file.getLastModifiedTime()); + + clock.advanceMillis(42000L); + file.setLastModifiedTime(-1L); + assertEquals(42000L, file.getLastModifiedTime()); + } } |