summaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authoraclement <aclement>2006-05-04 07:14:47 +0000
committeraclement <aclement>2006-05-04 07:14:47 +0000
commit5a01932b9dbdf81fe41e029fa56ede17364a2c2e (patch)
treea2991f73f2b496670e3de21f00538fbae9da891d /testing
parentcb5dfe759852d4965c692934ed7e14c41f61b715 (diff)
downloadaspectj-5a01932b9dbdf81fe41e029fa56ede17364a2c2e.tar.gz
aspectj-5a01932b9dbdf81fe41e029fa56ede17364a2c2e.zip
fixes for 137235 (contributed by Ron): more intelligent logic for determining if a path entry is a jar/zip (don't just rely on suffix, some new .bndl files seem to be becoming popular...)
Diffstat (limited to 'testing')
-rw-r--r--testing/newsrc/org/aspectj/testing/CompileSpec.java3
-rw-r--r--testing/newsrc/org/aspectj/testing/RunSpec.java51
-rw-r--r--testing/src/org/aspectj/testing/harness/bridge/Sandbox.java2
3 files changed, 47 insertions, 9 deletions
diff --git a/testing/newsrc/org/aspectj/testing/CompileSpec.java b/testing/newsrc/org/aspectj/testing/CompileSpec.java
index 6b98a6822..0d4d230eb 100644
--- a/testing/newsrc/org/aspectj/testing/CompileSpec.java
+++ b/testing/newsrc/org/aspectj/testing/CompileSpec.java
@@ -134,8 +134,7 @@ public class CompileSpec implements ITestStep {
* @param inpath The inpath to set.
*/
public void setInpath(String inpath) {
- this.inpath = inpath.replace(',',File.pathSeparatorChar);
- this.inpath = inpath.replace(';',File.pathSeparatorChar);
+ this.inpath = inpath.replace(',',File.pathSeparatorChar).replace(';',File.pathSeparatorChar);
}
/**
* @return Returns the options.
diff --git a/testing/newsrc/org/aspectj/testing/RunSpec.java b/testing/newsrc/org/aspectj/testing/RunSpec.java
index b879c95a2..485012104 100644
--- a/testing/newsrc/org/aspectj/testing/RunSpec.java
+++ b/testing/newsrc/org/aspectj/testing/RunSpec.java
@@ -14,7 +14,9 @@ package org.aspectj.testing;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Enumeration;
import java.util.List;
+import java.util.Properties;
import java.util.StringTokenizer;
import org.aspectj.tools.ajc.AjcTestCase;
@@ -53,12 +55,49 @@ public class RunSpec implements ITestStep {
// System.err.println("? execute() inTestCase='" + inTestCase + "', ltwFile=" + ltwFile);
boolean useLtw = copyLtwFile(inTestCase.getSandboxDirectory());
copyXlintFile(inTestCase.getSandboxDirectory());
- AjcTestCase.RunResult rr = inTestCase.run(getClassToRun(),args,getClasspath(),useLtw);
- if (stdErrSpec != null) {
- stdErrSpec.matchAgainst(rr.getStdErr());
+ try {
+ setSystemProperty("test.base.dir", inTestCase.getSandboxDirectory().getAbsolutePath());
+
+ AjcTestCase.RunResult rr = inTestCase.run(getClassToRun(),args,getClasspath(),useLtw);
+
+ if (stdErrSpec != null) {
+ stdErrSpec.matchAgainst(rr.getStdErr());
+ }
+ if (stdOutSpec != null) {
+ stdOutSpec.matchAgainst(rr.getStdOut());
+ }
+ } finally {
+ restoreProperties();
}
- if (stdOutSpec != null) {
- stdOutSpec.matchAgainst(rr.getStdOut());
+ }
+
+ /*
+ * Logic to save/restore system properties. Copied from LTWTests.
+ * As Matthew noted, need to refactor LTWTests to use this
+ */
+
+ private Properties savedProperties = new Properties();
+
+ public void setSystemProperty (String key, String value) {
+ Properties systemProperties = System.getProperties();
+ copyProperty(key,systemProperties,savedProperties);
+ systemProperties.setProperty(key,value);
+ }
+
+ private static void copyProperty (String key, Properties from, Properties to) {
+ String value = from.getProperty(key,NULL);
+ to.setProperty(key,value);
+ }
+
+ private final static String NULL = "null";
+
+ protected void restoreProperties() {
+ Properties systemProperties = System.getProperties();
+ for (Enumeration enu = savedProperties.keys(); enu.hasMoreElements(); ) {
+ String key = (String)enu.nextElement();
+ String value = savedProperties.getProperty(key);
+ if (value == NULL) systemProperties.remove(key);
+ else systemProperties.setProperty(key,value);
}
}
@@ -84,7 +123,7 @@ public class RunSpec implements ITestStep {
public String getClasspath() {
if (cpath == null) return null;
- return this.cpath.replace('/', File.separatorChar);
+ return this.cpath.replace('/', File.separatorChar).replace(',', File.pathSeparatorChar);
}
public void setClasspath(String cpath) {
diff --git a/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java b/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java
index 9388cf84e..c72d09285 100644
--- a/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java
+++ b/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java
@@ -510,7 +510,7 @@ public class Sandbox {
int len = (null == paths ? 0 : paths.length);
for (int j = 0; j < len; j++) {
File f = paths[j];
- if (FileUtil.hasZipSuffix(f) && (!readable || f.canRead())) {
+ if (FileUtil.isZipFile(f) && (!readable || f.canRead())) {
result.add(f);
}
}