Search in sources :

Example 31 with CeyloncTaskImpl

use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.

the class IssuesTests_1500_1999 method testBug1836.

@Test
public void testBug1836() {
    ErrorCollector collector = new ErrorCollector();
    CeyloncTaskImpl task = getCompilerTask(defaultOptions, collector, "bug18xx/Bug1836.ceylon");
    ExitState call2 = task.call2();
    Assert.assertEquals(CeylonState.ERROR, call2.ceylonState);
    Assert.assertEquals(Main.EXIT_ERROR, call2.javacExitCode.exitCode);
}
Also used : ExitState(org.eclipse.ceylon.compiler.java.launcher.Main.ExitState) ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) Test(org.junit.Test)

Example 32 with CeyloncTaskImpl

use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.

the class IssuesTests_2000_2499 method testBug2024.

@Test
public void testBug2024() {
    compile("bug20xx/bug2024a/module.ceylon", "bug20xx/bug2024a/package.ceylon", "bug20xx/bug2024a/Instant.ceylon");
    compile("bug20xx/bug2024b/module.ceylon", "bug20xx/bug2024b/Bug2024.ceylon", "bug20xx/bug2024b/Bug2024.java");
    compile("bug20xx/bug2024b/module.ceylon", "bug20xx/bug2024b/Bug2024.ceylon", "bug20xx/bug2024b/Bug2024B.java");
    // special case: a single package module
    List<String> options = new LinkedList<String>();
    options.add("-src");
    options.add(getPackagePath() + "/bug20xx");
    options.addAll(defaultOptions);
    CeyloncTaskImpl task = getCompilerTask(options, null, Arrays.asList("bug2024c"));
    Boolean ret = task.call();
    assertTrue(ret);
}
Also used : CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 33 with CeyloncTaskImpl

use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.

the class MiscTests method debugIncrementalCompilationBug.

/**
 * This test is for when we need to debug an incremental compilation error from the IDE, to make
 * sure it is indeed a bug and find which bug it is, do not enable it by default, it's only there
 * for debugging purpose. Once the bug is found, add it where it belongs (not here).
 */
@Ignore
@Test
public void debugIncrementalCompilationBug() {
    java.util.List<File> sourceFiles = new ArrayList<File>();
    String sdkSourcePath = "../../ceylon-sdk/source";
    String testSourcePath = "../../ceylon-sdk/test-source";
    for (String s : new String[] { "../../ceylon-sdk/source/ceylon/json/StringPrinter.ceylon", "../../ceylon-sdk/test-source/test/ceylon/json/print.ceylon", "../../ceylon-sdk/source/ceylon/json/Array.ceylon", "../../ceylon-sdk/test-source/test/ceylon/json/use.ceylon", "../../ceylon-sdk/source/ceylon/net/uri/Path.ceylon", "../../ceylon-sdk/test-source/test/ceylon/net/run.ceylon", "../../ceylon-sdk/source/ceylon/json/Printer.ceylon", "../../ceylon-sdk/source/ceylon/json/Object.ceylon", "../../ceylon-sdk/source/ceylon/net/uri/Query.ceylon", "../../ceylon-sdk/test-source/test/ceylon/json/run.ceylon", "../../ceylon-sdk/test-source/test/ceylon/net/connection.ceylon", "../../ceylon-sdk/source/ceylon/json/parse.ceylon", "../../ceylon-sdk/test-source/test/ceylon/json/parse.ceylon", "../../ceylon-sdk/source/ceylon/net/uri/PathSegment.ceylon" }) {
        sourceFiles.add(new File(s));
    }
    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;
    }
    CeyloncFileManager fileManager = (CeyloncFileManager) compiler.getStandardFileManager(null, null, null);
    Iterable<? extends JavaFileObject> compilationUnits1 = fileManager.getJavaFileObjectsFromFiles(sourceFiles);
    String compilerSourcePath = sdkSourcePath + File.pathSeparator + testSourcePath;
    CeyloncTaskImpl task = (CeyloncTaskImpl) compiler.getTask(null, fileManager, null, Arrays.asList("-sourcepath", compilerSourcePath, "-d", "../../ceylon-sdk/modules"), null, compilationUnits1);
    Boolean result = task.call();
    Assert.assertEquals("Compilation failed", Boolean.TRUE, result);
}
Also used : ArrayList(java.util.ArrayList) CeyloncTool(org.eclipse.ceylon.compiler.java.tools.CeyloncTool) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) File(java.io.File) CeyloncFileManager(org.eclipse.ceylon.compiler.java.tools.CeyloncFileManager) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 34 with CeyloncTaskImpl

use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.

the class MiscTests method compileSDKOnly.

private void compileSDKOnly(String[] modules, String[] extraModules) {
    String sourceDir = "../../ceylon-sdk/source";
    // 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) {
        moduleNames.add("ceylon." + module);
    }
    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, "-d", "build/classes-sdk", "-sysrep", getSysRepPath(), "-suppress-warnings", "ceylonNamespace", "-cp", getClassPathAsPath()), moduleNames, null);
    Boolean result = task.call();
    Assert.assertEquals("Compilation of SDK itself 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 35 with CeyloncTaskImpl

use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.

the class MiscTests method compileRuntime.

@Test
public void compileRuntime() {
    cleanCars("build/classes-runtime");
    java.util.List<File> sourceFiles = new ArrayList<File>();
    String ceylonSourcePath = "../language/src";
    String javaSourcePath = "../language/runtime";
    String[] ceylonPackages = { "ceylon.language", "ceylon.language.meta", "ceylon.language.impl", "ceylon.language.meta.declaration", "ceylon.language.meta.model", "ceylon.language.serialization" };
    // Native files
    FileFilter exceptions = new FileFilter() {

        @Override
        public boolean accept(File pathname) {
            String filename = pathname.getName();
            filename = filename.substring(0, filename.lastIndexOf('.'));
            for (String s : new String[] { "Boolean", "Integer", "Float", "Character", "String", "Byte", "Array", "Tuple", "Exception", "AssertionError", "Callable", "flatten", "className", "integerRangeByIterable", "modules", "printStackTrace", "Throwable", "type", "typeLiteral", "classDeclaration", "reach", "unflatten", "serialization", "PartialImpl" }) {
                if (s.equals(filename)) {
                    return true;
                }
            }
            if (filename.equals("annotations") && pathname.getParentFile().getName().equals("meta")) {
                return true;
            }
            return false;
        }
    };
    String[] extras = new String[] { "true", "false", "arrayToTuple" };
    String[] modelExtras = new String[] { "classDeclaration", "annotations", "modules", "type", "typeLiteral" };
    String[] s11nExtras = new String[] { "PartialImpl" };
    for (String pkg : ceylonPackages) {
        File pkgDir = new File(ceylonSourcePath, pkg.replaceAll("\\.", "/"));
        File javaPkgDir = new File(javaSourcePath, pkg.replaceAll("\\.", "/"));
        File[] files = pkgDir.listFiles();
        if (files != null) {
            for (File src : files) {
                if (src.isFile() && src.getName().toLowerCase().endsWith(".ceylon")) {
                    String baseName = src.getName().substring(0, src.getName().length() - 7);
                    if (!exceptions.accept(src)) {
                        sourceFiles.add(src);
                    } else {
                        addJavaSourceFile(baseName, sourceFiles, javaPkgDir, false);
                    }
                }
            }
        }
    }
    // add extra files that are in Java
    File javaPkgDir = new File(javaSourcePath, "ceylon/language");
    for (String extra : extras) addJavaSourceFile(extra, sourceFiles, javaPkgDir, true);
    File javaModelPkgDir = new File(javaSourcePath, "ceylon/language/meta");
    for (String extra : modelExtras) addJavaSourceFile(extra, sourceFiles, javaModelPkgDir, true);
    File javaS11nPkgDir = new File(javaSourcePath, "ceylon/language/serialization");
    for (String extra : s11nExtras) addJavaSourceFile(extra, sourceFiles, javaS11nPkgDir, true);
    File javaS11nEPkgDir = new File(javaSourcePath, "ceylon/language/impl");
    for (String extra : new String[] { "reach" }) addJavaSourceFile(extra, sourceFiles, javaS11nEPkgDir, true);
    String[] javaPackages = { "org/eclipse/ceylon/compiler/java", "org/eclipse/ceylon/compiler/java/language", "org/eclipse/ceylon/compiler/java/metadata", "org/eclipse/ceylon/compiler/java/runtime/ide", "org/eclipse/ceylon/compiler/java/runtime/metamodel", "org/eclipse/ceylon/compiler/java/runtime/model", "org/eclipse/ceylon/compiler/java/runtime/metamodel/decl", "org/eclipse/ceylon/compiler/java/runtime/metamodel/meta", "org/eclipse/ceylon/compiler/java/runtime/serialization", "org/eclipse/ceylon/compiler/java/wrapping" };
    for (String pkg : javaPackages) {
        File pkgDir = new File(javaSourcePath, pkg.replaceAll("\\.", "/"));
        File[] files = pkgDir.listFiles();
        if (files != null) {
            for (File src : files) {
                if (src.isFile() && src.getName().toLowerCase().endsWith(".java")) {
                    sourceFiles.add(src);
                }
            }
        }
    }
    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;
    }
    CeyloncFileManager fileManager = (CeyloncFileManager) compiler.getStandardFileManager(null, null, null);
    Iterable<? extends JavaFileObject> compilationUnits1 = fileManager.getJavaFileObjectsFromFiles(sourceFiles);
    String compilerSourcePath = ceylonSourcePath + File.pathSeparator + javaSourcePath;
    CeyloncTaskImpl task = (CeyloncTaskImpl) compiler.getTask(null, fileManager, null, Arrays.asList("-sourcepath", compilerSourcePath, "-d", "build/classes-runtime", "-Xbootstrapceylon", "-cp", getClassPathAsPathExcludingLanguageModule(), "-suppress-warnings", "ceylonNamespace"), null, compilationUnits1);
    Boolean result = task.call();
    Assert.assertEquals("Compilation failed", Boolean.TRUE, result);
}
Also used : ArrayList(java.util.ArrayList) CeyloncTool(org.eclipse.ceylon.compiler.java.tools.CeyloncTool) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) FileFilter(java.io.FileFilter) File(java.io.File) CeyloncFileManager(org.eclipse.ceylon.compiler.java.tools.CeyloncFileManager) Test(org.junit.Test)

Aggregations

CeyloncTaskImpl (org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl)62 Test (org.junit.Test)51 File (java.io.File)34 JarFile (java.util.jar.JarFile)26 LinkedList (java.util.LinkedList)23 ErrorCollector (org.eclipse.ceylon.compiler.java.test.ErrorCollector)23 ZipEntry (java.util.zip.ZipEntry)13 ZipFile (java.util.zip.ZipFile)13 CompilerError (org.eclipse.ceylon.compiler.java.test.CompilerError)12 ExitState (org.eclipse.ceylon.compiler.java.launcher.Main.ExitState)7 CeyloncTool (org.eclipse.ceylon.compiler.java.tools.CeyloncTool)6 ArrayList (java.util.ArrayList)5 CeyloncFileManager (org.eclipse.ceylon.compiler.java.tools.CeyloncFileManager)5 TaskEvent (org.eclipse.ceylon.langtools.source.util.TaskEvent)4 TaskListener (org.eclipse.ceylon.langtools.source.util.TaskListener)4 Set (java.util.Set)3 DiagnosticListener (org.eclipse.ceylon.javax.tools.DiagnosticListener)3 JCCompilationUnit (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCCompilationUnit)3 Module (org.eclipse.ceylon.model.typechecker.model.Module)3 Ignore (org.junit.Ignore)3