ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/testcases/org/apache/tools/ant/taskdefs/optional/unix SymlinkTest.java
Date Mon, 07 Jun 2004 12:03:56 GMT
bodewig     2004/06/07 05:03:56

  Modified:    src/etc/testcases/taskdefs/optional/unix Tag: ANT_16_BRANCH
                        symlink.xml
               src/main/org/apache/tools/ant/taskdefs/optional/unix Tag:
                        ANT_16_BRANCH Symlink.java
               src/testcases/org/apache/tools/ant/taskdefs/optional/unix
                        Tag: ANT_16_BRANCH SymlinkTest.java
  Log:
  merge
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.1   +49 -2     ant/src/etc/testcases/taskdefs/optional/unix/symlink.xml
  
  Index: symlink.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/optional/unix/symlink.xml,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- symlink.xml	7 Nov 2002 16:52:07 -0000	1.1
  +++ symlink.xml	7 Jun 2004 12:03:55 -0000	1.1.2.1
  @@ -104,6 +104,8 @@
            Link: ${tdir}/symtest1/symtest2/link3==>
                                              ${tdir}/symtest1/symtest2/file2
            Link: ${tdir}/symtest1/dirlink==>${tdir}/symtest1/symtest3
  +         Link: ${tdir}/symtest1/dirlink2==>${tdir}/symtest1/symtest3
  +         Link: ${tdir}/symtest1/dirlink3==>${tdir}/symtest1/symtest3
            File: ${tdir}/symtest1/recorded.links
            File: ${tdir}/symtest1/symtest2/recorded.links
       Deletes:
  @@ -134,6 +136,12 @@
       <symlink resource="${tdir}/symtest1/symtest3"
                link="${tdir}/symtest1/dirlink"
                failonerror="no" />
  +    <symlink resource="${tdir}/symtest1/symtest3" 
  +             link="${tdir}/symtest1/dirlink2"
  +             failonerror="no"/>
  +    <symlink resource="${tdir}/symtest1/symtest3" 
  +             link="${tdir}/symtest1/dirlink3"
  +             failonerror="no"/>
   
       <sleep seconds="${delay}"/> <!-- make sure OS has time to catch up -->
   
  @@ -188,6 +196,11 @@
       <available file="${tdir}/symtest1/dirlink"
                  property="test.record.dirlink.created"/>
   
  +    <!-- this is redundant for this test, but used in the recreate test -->
  +
  +    <available file="${tdir}/symtest1/dirlink2" 
  +               property="test.record.dirlink2.created"/>
  +
       <!-- Test to see if the linkfiles were created -->
   
       <available file="${tdir}/symtest1/recorded.links"
  @@ -213,14 +226,26 @@
            Link: ${tdir}/symtest1/link2==>${tdir}/symtest1/symtest2/file2
            Link: ${tdir}/symtest1/symtest2/link3==>
                                              ${tdir}/symtest1/symtest2/file2
  -         Link: ${tdir}/sumtest1/dirlink==>${tdir}/symtest1/symtest3
  +         Link: ${tdir}/symtest1/dirlink==>${tdir}/symtest1/symtest3
  +         Link: ${tdir}/symtest1/dirlink3==>${tdir}/symtest1/symtest3
  +
  +    Creates
  +         Link: ${tdir}/symtest1/dirlink3==>${tdir}/symtest1/symtest2
   
       Recreates:
            Link: ${tdir}/symtest1/link1==>${tdir}/symtest1/file1
            Link: ${tdir}/symtest1/link2==>${tdir}/symtest1/symtest2/file2
            Link: ${tdir}/symtest1/symtest2/link3==>
                                              ${tdir}/symtest1/symtest2/file2
  -         Link: ${tdir}/sumtest1/dirlink==>${tdir}/symtest1/symtest3
  +         Link: ${tdir}/symtest1/dirlink==>${tdir}/symtest1/symtest3
  +
  +    Should Change:
  +         Link: ${tdir}/symtest1/dirlink3==>${tdir}/symtest1/symtest2
  +               to
  +               ${tdir}/symtest1/dirlink3==>${tdir}/symtest1/symtest3
  +
  +    Should Not Create (bug 25181):
  +         Link: ${tdir}/symtest1/symtest3/dirlink2==>${tdir}/symtest1/symtest3
     -->
   
     <target name="test-recreate" depends="test-record">
  @@ -229,6 +254,16 @@
       <symlink action="delete" link="${tdir}/symtest1/link2"/>
       <symlink action="delete" link="${tdir}/symtest1/symtest2/link3"/>
       <symlink action="delete" link="${tdir}/symtest1/dirlink"/>
  +    <!-- dirlink2 intentionally not deleted to test bug 25181 -->
  +    <symlink action="delete" link="${tdir}/symtest1/dirlink3"/>
  +
  +    <sleep seconds="${delay}"/>  <!-- make sure OS has time to catch up -->
  +
  +    <symlink resource="${tdir}/symtest1/symtest2" 
  +             link="${tdir}/symtest1/dirlink3"
  +             failonerror="no"/>
  +
  +    <sleep seconds="${delay}"/>  <!-- make sure OS has time to catch up -->
   
       <available file="${tdir}/symtest1/link1"
                  property="test.recreate.link1.not.removed"
  @@ -265,6 +300,18 @@
   
       <available file="${tdir}/symtest1/dirlink"
                  property="test.recreate.dirlink.recreated"/>
  +
  +    <!-- this should not get set -->
  +    <available file="${tdir}/symtest1/symtest3/symtest3" 
  +               property="test.recreate.dirlink2.recreated.twice"
  +               value="ERROR: dirlink2 was created a second time (bug 25181)"/>
  +
  +    <touch file="${tdir}/symtest1/dirlink3/WhereAmI"/>
  +
  +    <sleep seconds="${delay}"/>  <!-- make sure OS has time to do the execs -->
  +
  +    <available file="${tdir}/symtest1/symtest3/WhereAmI" 
  +               property="test.recreate.dirlink3.was.altered"/>
     </target>
   
   
  
  
  
  No                   revision
  No                   revision
  1.12.2.6  +21 -3     ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
  
  Index: Symlink.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java,v
  retrieving revision 1.12.2.5
  retrieving revision 1.12.2.6
  diff -u -r1.12.2.5 -r1.12.2.6
  --- Symlink.java	9 Mar 2004 17:01:53 -0000	1.12.2.5
  +++ Symlink.java	7 Jun 2004 12:03:55 -0000	1.12.2.6
  @@ -160,7 +160,26 @@
                   while (keys.hasMoreElements()) {
                       link = (String) keys.nextElement();
                       resource = listOfLinks.getProperty(link);
  -                    doLink(resource, link);
  +		    // handle the case where the link exists 
  +		    // and points to a directory (bug 25181)
  +		    try {
  +			FileUtils fu = FileUtils.newFileUtils();
  +			File test = new File(link);
  +			File testRes = new File(resource);
  +			if (!fu.isSymbolicLink(test.getParentFile(), 
  +					       test.getName())) {
  +			    doLink(resource, link);
  +			} else {
  +			    if (!test.getCanonicalPath().
  +			    	equals(testRes.getCanonicalPath())) {
  +			    	Symlink.deleteSymlink(link);
  +			    	doLink(resource,link);
  +			    } // else the link exists, do nothing
  +			}
  +		    } catch (IOException ioe) {
  +			handleError("IO exception while creating "
  +				    + "link");
  +		    }
                   }
               } else if (action.equals("record")) {
                   Vector vectOfLinks;
  @@ -735,7 +754,6 @@
                   keys = propTemp.keys();
                   propTemp.list(System.out);
                   // Write the contents to our master list of links
  -
                   // This method assumes that all links are defined in
                   // terms of absolute paths, or paths relative to the
                   // working directory
  
  
  
  No                   revision
  No                   revision
  1.3.2.5   +14 -1     ant/src/testcases/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java
  
  Index: SymlinkTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java,v
  retrieving revision 1.3.2.4
  retrieving revision 1.3.2.5
  diff -u -r1.3.2.4 -r1.3.2.5
  --- SymlinkTest.java	9 Mar 2004 17:02:07 -0000	1.3.2.4
  +++ SymlinkTest.java	7 Jun 2004 12:03:55 -0000	1.3.2.5
  @@ -128,6 +128,9 @@
               assertNotNull("Failed to create dirlink",
                             p.getProperty("test.record.dirlink.created"));
   
  +            assertNotNull("Failed to create dirlink2",
  +                          p.getProperty("test.record.dirlink2.created"));
  +
               assertNotNull("Couldn't record links in dir1",
                             p.getProperty("test.record.dir1.recorded"));
   
  @@ -173,6 +176,16 @@
                             p.getProperty("test.recreate.link3.recreated"));
               assertNotNull("Failed to recreate dirlink",
                             p.getProperty("test.recreate.dirlink.recreated"));
  +	    
  +	    String doubleRecreate = p.getProperty("test.recreate.dirlink2.recreated.twice");
  +
  +	    if (doubleRecreate != null) {
  +		fail(doubleRecreate);
  +	    }
  +
  +            assertNotNull("Failed to alter dirlink3",
  +                          p.getProperty("test.recreate.dirlink3.was.altered"));
  +
           }
           testfail = false;
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message