Browse Source

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
master
Steve Loughran 21 years ago
parent
commit
ea016c9845
1 changed files with 22 additions and 3 deletions
  1. +22
    -3
      src/testcases/org/apache/tools/ant/util/FileUtilsTest.java

+ 22
- 3
src/testcases/org/apache/tools/ant/util/FileUtilsTest.java View File

@@ -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
*/


Loading…
Cancel
Save