From 35e6b8dd1ad6b8a683c6df2da2404d88d804e0f6 Mon Sep 17 00:00:00 2001 From: wisberg Date: Fri, 9 May 2003 07:14:19 +0000 Subject: [PATCH] Fixing Harness bug of adding the output directory to the classpath, which conceals a bug in the incremental compilation. This change should have no effect on other tests, but I noticed two other failures during normal compiles caused by inability to resolve type names. --- .../aspectj/testing/harness/bridge/CompilerRun.java | 13 +++++++++---- .../testing/harness/bridge/IncCompilerRun.java | 1 - .../org/aspectj/testing/harness/bridge/JavaRun.java | 5 +++-- .../org/aspectj/testing/harness/bridge/Sandbox.java | 9 ++++++++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java b/testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java index 3d6011281..853a853dc 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java +++ b/testing/src/org/aspectj/testing/harness/bridge/CompilerRun.java @@ -197,18 +197,24 @@ public class CompilerRun implements IAjcRun { } } else { // staging - copy files try { + // copy all files, then remove tagged ones + // XXX make copyFiles support a filter? srcFiles = FileUtil.copyFiles(testBaseSrcDir, srcPaths, sandbox.stagingDir); if (!LangUtil.isEmpty(spec.sourceroots)) { sourcerootFiles = FileUtil.copyFiles(testBaseSrcDir, spec.sourceroots, sandbox.stagingDir); // delete incremental files in sourceroot after copying // XXX inefficient FileFilter pickIncFiles = new FileFilter() { - // XXX weak rule to find incremental files + // an incremental file has an extra "." in name + // most .java files don't, because they are named after + // the principle type they contain, and simple type names + // have no dots. public boolean accept(File file) { if (file.isDirectory()) { // continue recursion return true; } String path = file.getPath(); - if (!FileUtil.hasSourceSuffix(path)) { + // only source files are relevant to staging + if (!FileUtil.hasSourceSuffix(path)) { return false; } int first = path.indexOf("."); @@ -256,10 +262,9 @@ public class CompilerRun implements IAjcRun { // save classpath and aspectpath in sandbox for this and other clients final boolean checkReadable = true; // hmm - third validation? - File[] cp = new File[3 + classFiles.length]; + File[] cp = new File[2 + classFiles.length]; System.arraycopy(classFiles, 0, cp, 0, classFiles.length); int index = classFiles.length; - cp[index++] = sandbox.classesDir; cp[index++] = Globals.F_aspectjrt_jar; cp[index++] = Globals.F_testingclient_jar; sandbox.setClasspath(cp, checkReadable, this); diff --git a/testing/src/org/aspectj/testing/harness/bridge/IncCompilerRun.java b/testing/src/org/aspectj/testing/harness/bridge/IncCompilerRun.java index ba7a9310a..3c8d4a032 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/IncCompilerRun.java +++ b/testing/src/org/aspectj/testing/harness/bridge/IncCompilerRun.java @@ -100,7 +100,6 @@ public class IncCompilerRun implements IAjcRun { } boolean result = false; try { - //ArrayList changed = new ArrayList(); final String toSuffix = ".java"; final String fromSuffix = "." + spec.tag + toSuffix; // copy our tagged generation of files to the staging directory, diff --git a/testing/src/org/aspectj/testing/harness/bridge/JavaRun.java b/testing/src/org/aspectj/testing/harness/bridge/JavaRun.java index 5c236dbac..350550f1d 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/JavaRun.java +++ b/testing/src/org/aspectj/testing/harness/bridge/JavaRun.java @@ -108,7 +108,7 @@ public class JavaRun implements IAjcRun { && validator.canReadDir(sandbox.getTestBaseSrcDir(this), "testBaseSrc dir") && validator.canWriteDir(sandbox.runDir, "run dir") && validator.canReadFiles(sandbox.getClasspathJars(true, this), "classpath jars") - && validator.canReadDirs(sandbox.getClasspathDirectories(true, this), "classpath dirs") + && validator.canReadDirs(sandbox.getClasspathDirectories(true, this, true), "classpath dirs") ); } @@ -126,7 +126,8 @@ public class JavaRun implements IAjcRun { try { final boolean readable = true; File[] libs = sandbox.getClasspathJars(readable, this); - File[] dirs = sandbox.getClasspathDirectories(readable, this); + boolean includeClassesDir = true; + File[] dirs = sandbox.getClasspathDirectories(readable, this, includeClassesDir); completedNormally = FORK // || spec.fork ? runInOtherVM(status, libs, dirs) : runInSameVM(status, libs, dirs); diff --git a/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java b/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java index a9a742106..6f03199c4 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java +++ b/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java @@ -403,7 +403,10 @@ public class Sandbox { * This ignores aspectpath since it may contain only jar files. * @param readable if true, omit non-readable directories */ - File[] getClasspathDirectories(boolean readable, JavaRun caller) { + File[] getClasspathDirectories( + boolean readable, + JavaRun caller, + boolean includeOutput) { LangUtil.throwIaxIfNull(caller, "caller"); assertState(null != compileClasspath, "classpath not set"); ArrayList result = new ArrayList(); @@ -414,6 +417,10 @@ public class Sandbox { result.add(f); } } + if (includeOutput && (null != classesDir) + && (!readable || classesDir.canRead())) { + result.add(classesDir); + } return (File[]) result.toArray(new File[0]); } -- 2.39.5