Search in sources :

Example 6 with CeyloncFileManager

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);
}
Also used : ArrayList(java.util.ArrayList) CeyloncTool(org.eclipse.ceylon.compiler.java.tools.CeyloncTool) ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) File(java.io.File) CeyloncFileManager(org.eclipse.ceylon.compiler.java.tools.CeyloncFileManager)

Example 7 with CeyloncFileManager

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);
}
Also used : ArrayList(java.util.ArrayList) CeyloncTool(org.eclipse.ceylon.compiler.java.tools.CeyloncTool) ZipFile(java.util.zip.ZipFile) File(java.io.File) CeyloncFileManager(org.eclipse.ceylon.compiler.java.tools.CeyloncFileManager) LinkedList(java.util.LinkedList)

Aggregations

CeyloncFileManager (org.eclipse.ceylon.compiler.java.tools.CeyloncFileManager)7 File (java.io.File)6 ArrayList (java.util.ArrayList)6 CeyloncTool (org.eclipse.ceylon.compiler.java.tools.CeyloncTool)6 CeyloncTaskImpl (org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl)5 ErrorCollector (org.eclipse.ceylon.compiler.java.test.ErrorCollector)3 Test (org.junit.Test)3 LinkedList (java.util.LinkedList)2 FileFilter (java.io.FileFilter)1 StringWriter (java.io.StringWriter)1 ZipFile (java.util.zip.ZipFile)1 LanguageCompiler (org.eclipse.ceylon.compiler.java.tools.LanguageCompiler)1 JavaFileManager (org.eclipse.ceylon.javax.tools.JavaFileManager)1 StandardJavaFileManager (org.eclipse.ceylon.javax.tools.StandardJavaFileManager)1 Ignore (org.junit.Ignore)1