From 2487a905056a72e96e91a8116eb3d150d96e5469 Mon Sep 17 00:00:00 2001 From: Antoine Levy-Lambert Date: Mon, 18 Feb 2013 19:37:49 +0000 Subject: [PATCH] fix test error happening under Windows @ Jetbrains see http://teamcity.jetbrains.com/viewType.html?buildTypeId=bt133 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1447450 13f79535-47bb-0310-9956-ffa450edef68 --- .../ant/taskdefs/ManifestClassPathTest.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java index 4b3cfbdc1..fb7c3a9b4 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java @@ -22,6 +22,9 @@ import org.apache.tools.ant.BuildFileTest; 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>. */ @@ -167,10 +170,27 @@ public class ManifestClassPathTest 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; }