Commits

Anonymous committed ca836c1
  • Participants
  • Parent commits 87aca5e

Comments (0)

Files changed (1)

src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java

 import org.apache.tools.ant.taskdefs.condition.Os;
 import org.apache.tools.ant.util.regexp.RegexpMatcherFactory;
 
+import java.io.File;
+import java.io.IOException;
+
 /**
  * Tests <bm:manifestclasspath>.
  */
         if (!Os.isFamily("windows")) {
             System.out.println("Test with drive letters only run on windows");
         } else {
+            // the lines below try to find a drive name different than the one containing the temp dir
+            // if the temp dir is C will try to use D
+            // if the temp dir is on D or other will try to use C
+            File tmpdir = new File(System.getProperty("java.io.tmpdir"));
+            String driveLetter = "C";
+            try {
+                String tmpCanonicalPath = tmpdir.getCanonicalPath();
+                driveLetter = tmpCanonicalPath.substring(1).toUpperCase();
+            } catch (IOException ioe) {
+                System.out.println("exception happened getting canonical path of java.io.tmpdir : " + ioe.getMessage());
+            }
+            String altDriveLetter = null;
             try {
-                new java.io.File("D:/foo.txt").getCanonicalPath();
+                if ("C".equals(driveLetter)) {
+                    altDriveLetter = "D";
+                } else {
+                    altDriveLetter = "C";
+                }
+                new java.io.File(altDriveLetter + ":/foo.txt").getCanonicalPath();
             } catch (java.io.IOException e) {
-                System.out.println("drive d: doesn't exist or is not ready,"
+                System.out.println("drive " + altDriveLetter + ": doesn't exist or is not ready,"
                                    + " skipping test");
                 return;
             }