From ea016c98458c951c4f7bcf4cf3bcdad3eb9899fa Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Sun, 8 Aug 2004 21:03:21 +0000 Subject: [PATCH] fixed the test failure, added a proper self contained test. I have commented out the test that asserts that sourceTime==destTime implies up-to-dateness. This is an interesting problem. Filesys granularity gets in the way. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276761 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/util/FileUtilsTest.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java b/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java index 26e084257..aaf35c9ca 100644 --- a/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java +++ b/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java @@ -83,9 +83,6 @@ public class FileUtilsTest extends TestCase { long secondModTime = removeThis.lastModified(); assertTrue(secondModTime > modTime); - //check that the isUpToDate logic works - assertFalse(fu.isUpToDate(modTime,secondModTime)); - // number of milliseconds in a day final int millisperday=24 * 3600 * 1000; // in a previous version, the date of the file was set to 123456 @@ -438,6 +435,28 @@ public class FileUtilsTest extends TestCase { assertEqualsIgnoreDriveCase(localize("/foo#bar"), fu.fromURI("file:///foo%23bar")); } + public void testModificationTests() { + + //get a time + long firstTime=System.currentTimeMillis(); + //add some time. We assume no OS has a granularity this bad + long secondTime=firstTime+60000; +/* + assertTrue("same timestamp is up to date", + fu.isUpToDate(firstTime, firstTime)); + */ + + //check that older is up to date with a newer dest + assertTrue("older source files are up to date", + fu.isUpToDate(firstTime,secondTime)); + //check that older is up to date with a newer dest + assertFalse("newer source files are no up to date", + fu.isUpToDate(secondTime, firstTime)); + + assertTrue("-1 dest timestamp implies nonexistence", + !fu.isUpToDate(firstTime,-1L)); + } + /** * adapt file separators to local conventions */