use of org.eclipse.ceylon.compiler.java.tools.CeyloncFileManager in project ceylon by eclipse.
the class MiscTests method compileSDKTests.
private void compileSDKTests(String[] modules, String[] extraModules) {
String sourceDir = "../../ceylon-sdk/test-source";
String depsDir = "../../ceylon-sdk/test-deps";
// don't run this if the SDK is not checked out
File sdkFile = new File(sourceDir);
if (!sdkFile.exists())
return;
java.util.List<String> moduleNames = new ArrayList<String>(modules.length);
for (String module : modules) {
String name = "test.ceylon." + module;
// only add it if it exists
if (new File(sourceDir, name.replace('.', File.separatorChar)).isDirectory())
moduleNames.add(name);
}
for (String module : extraModules) {
moduleNames.add(module);
}
CeyloncTool compiler;
try {
compiler = new CeyloncTool();
} catch (VerifyError e) {
System.err.println("ERROR: Cannot run tests! Did you maybe forget to configure the -Xbootclasspath/p: parameter?");
throw e;
}
ErrorCollector errorCollector = new ErrorCollector();
CeyloncFileManager fileManager = (CeyloncFileManager) compiler.getStandardFileManager(null, null, null);
CeyloncTaskImpl task = (CeyloncTaskImpl) compiler.getTask(null, fileManager, errorCollector, Arrays.asList("-sourcepath", sourceDir, "-sysrep", getSysRepPath(), "-rep", depsDir, "-d", "build/classes-sdk", "-cp", getClassPathAsPath()), moduleNames, null);
Boolean result = task.call();
Assert.assertEquals("Compilation of SDK tests failed:" + errorCollector.getAssertionFailureMessage(), Boolean.TRUE, result);
}
use of org.eclipse.ceylon.compiler.java.tools.CeyloncFileManager in project ceylon by eclipse.
the class CompilerTests method getCompilerTask.
protected CeyloncTaskImpl getCompilerTask(List<String> initialOptions, DiagnosticListener<? super FileObject> diagnosticListener, List<String> modules, String... sourcePaths) {
java.util.List<File> sourceFiles = new ArrayList<File>(sourcePaths.length);
for (String file : sourcePaths) {
sourceFiles.add(new File(getPackagePath(), file));
}
CeyloncTool runCompiler = makeCompiler();
CeyloncFileManager runFileManager = makeFileManager(runCompiler, diagnosticListener);
// make sure the destination repo exists
new File(destDir).mkdirs();
List<String> options = new LinkedList<String>();
options.addAll(initialOptions);
if (!options.contains("-out"))
options.addAll(Arrays.asList("-out", destDir));
if (!options.contains("-src"))
options.addAll(Arrays.asList("-src", getSourcePath()));
if (!options.contains("-cacherep"))
options.addAll(Arrays.asList("-cacherep", getCachePath()));
if (!options.contains("-sysrep"))
options.addAll(Arrays.asList("-sysrep", getSysRepPath()));
if (!options.contains("-cp"))
options.addAll(Arrays.asList("-cp", getClassPathAsPath()));
boolean hasVerbose = false;
for (String option : options) {
if (option.startsWith("-verbose")) {
hasVerbose = true;
break;
}
}
if (!hasVerbose)
options.add("-verbose:ast,code");
Iterable<? extends JavaFileObject> compilationUnits1 = runFileManager.getJavaFileObjectsFromFiles(sourceFiles);
return runCompiler.getTask(null, runFileManager, diagnosticListener, options, modules, compilationUnits1);
}
Aggregations