From 102e7eafb01e702412c318c6ff189e562be7924e Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Thu, 23 Feb 2012 23:26:30 +0100 Subject: Make the unittests for ecj work on windows --- test/core/src/lombok/RunTestsViaEcj.java | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/core/src/lombok/RunTestsViaEcj.java b/test/core/src/lombok/RunTestsViaEcj.java index 1d879a35..5c573efd 100644 --- a/test/core/src/lombok/RunTestsViaEcj.java +++ b/test/core/src/lombok/RunTestsViaEcj.java @@ -26,6 +26,7 @@ import java.io.StringWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -92,18 +93,10 @@ public class RunTestsViaEcj extends AbstractRunTests { } }; - List classpath = new ArrayList(); - classpath.addAll(Arrays.asList(System.getProperty("sun.boot.class.path").split(File.pathSeparator))); - classpath.add("dist/lombok.jar"); - classpath.add("lib/test/commons-logging.jar"); - classpath.add("lib/test/slf4j-api.jar"); - classpath.add("lib/test/log4j.jar"); - FileSystem fileAccess = new FileSystem(classpath.toArray(new String[0]), new String[] {file.getAbsolutePath()}, "UTF-8"); - String source = readFile(file); final CompilationUnit sourceUnit = new CompilationUnit(source.toCharArray(), file.getName(), "UTF-8"); - Compiler ecjCompiler = new Compiler(fileAccess, ecjErrorHandlingPolicy(), ecjCompilerOptions(), bitbucketRequestor, new DefaultProblemFactory(Locale.ENGLISH)) { + Compiler ecjCompiler = new Compiler(createFileSystem(file), ecjErrorHandlingPolicy(), ecjCompilerOptions(), bitbucketRequestor, new DefaultProblemFactory(Locale.ENGLISH)) { @Override protected synchronized void addCompilationUnit(ICompilationUnit inUnit, CompilationUnitDeclaration parsedUnit) { if (inUnit == sourceUnit) compilationUnit_.set(parsedUnit); super.addCompilationUnit(inUnit, parsedUnit); @@ -123,4 +116,19 @@ public class RunTestsViaEcj extends AbstractRunTests { result.append(cud.toString()); } + + private FileSystem createFileSystem(File file) { + List classpath = new ArrayList(); + classpath.addAll(Arrays.asList(System.getProperty("sun.boot.class.path").split(File.pathSeparator))); + for (Iterator i = classpath.iterator(); i.hasNext();) { + if (FileSystem.getClasspath(i.next(), "UTF-8", null) == null) { + i.remove(); + } + } + classpath.add("dist/lombok.jar"); + classpath.add("lib/test/commons-logging.jar"); + classpath.add("lib/test/slf4j-api.jar"); + classpath.add("lib/test/log4j.jar"); + return new FileSystem(classpath.toArray(new String[0]), new String[] {file.getAbsolutePath()}, "UTF-8"); + } } -- cgit