Bug 572138: Add isWindows check back to CoreTests
This reverts commit 2c70a60dbee6444f710f4fe6d6482937a5c2c4b3.
Change-Id: Iec8af8452232fb3d67ef37fd88f93d3506ba0a77
Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
diff --git a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/CoreTest.java b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/CoreTest.java
index 33016fe..2a4e8c1 100644
--- a/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/CoreTest.java
+++ b/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/CoreTest.java
@@ -237,11 +237,16 @@
String[] envp = {};
try {
Process p;
- if (isDir) {
- String[] cmd = { "cmd", "/c", "mklink", "/d", linkName, linkTarget };
- p = Runtime.getRuntime().exec(cmd, envp, basedir);
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ if (isDir) {
+ String[] cmd = {"cmd", "/c", "mklink", "/d", linkName, linkTarget};
+ p = Runtime.getRuntime().exec(cmd, envp, basedir);
+ } else {
+ String[] cmd = {"cmd", "/c", "mklink", linkName, linkTarget};
+ p = Runtime.getRuntime().exec(cmd, envp, basedir);
+ }
} else {
- String[] cmd = { "cmd", "/c", "mklink", linkName, linkTarget };
+ String[] cmd = {"ln", "-s", linkTarget, linkName};
p = Runtime.getRuntime().exec(cmd, envp, basedir);
}
int exitcode = p.waitFor();
@@ -261,19 +266,23 @@
*/
protected boolean canCreateSymLinks() {
if (canCreateSymLinks == null) {
- // Creation of a symbolic link on Windows requires administrator privileges,
- // so it may or may not be possible.
- IPath tempDir = getTempDir();
- String linkName = FileSystemHelper.getRandomLocation(tempDir).lastSegment();
- try {
- // Try to create a symlink.
- createSymLink(tempDir.toFile(), linkName, "testTarget", false);
- // Clean up if the link was created.
- new File(tempDir.toFile(), linkName).delete();
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ // Creation of a symbolic link on Windows requires administrator privileges,
+ // so it may or may not be possible.
+ IPath tempDir = getTempDir();
+ String linkName = FileSystemHelper.getRandomLocation(tempDir).lastSegment();
+ try {
+ // Try to create a symlink.
+ createSymLink(tempDir.toFile(), linkName, "testTarget", false);
+ // Clean up if the link was created.
+ new File(tempDir.toFile(), linkName).delete();
+ canCreateSymLinks = Boolean.TRUE;
+ } catch (AssertionFailedError e) {
+ // This exception indicates that creation of the symlink failed.
+ canCreateSymLinks = Boolean.FALSE;
+ }
+ } else {
canCreateSymLinks = Boolean.TRUE;
- } catch (AssertionFailedError e) {
- // This exception indicates that creation of the symlink failed.
- canCreateSymLinks = Boolean.FALSE;
}
}
return canCreateSymLinks.booleanValue();
@@ -362,7 +371,6 @@
return System.currentTimeMillis() + "-" + Math.random();
}
-
/**
* Copy the data from the input stream to the output stream.
* Close both streams when finished.