Search in sources :

Example 31 with CeyloncTaskImpl

use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.

the class IssuesTests_1500_1999 method testBug1773.

@Test
public void testBug1773() {
    ErrorCollector collector = new ErrorCollector();
    CeyloncTaskImpl task = getCompilerTask(defaultOptions, collector, "bug17xx/Bug1773.ceylon");
    // now compile it all the way
    ExitState exitState = task.call2();
    Assert.assertEquals(ExitState.CeylonState.ERROR, exitState.ceylonState);
    // make sure we only got one, do not trust actualErrors.size() for that since it's a Set so
    // two methods with same contents would count as one.
    Assert.assertEquals(1, exitState.errorCount);
    TreeSet<CompilerError> actualErrors = collector.get(Diagnostic.Kind.ERROR);
    compareErrors(actualErrors, new CompilerError(22, "dynamic is not supported on the JVM"));
}
Also used : ExitState(com.redhat.ceylon.compiler.java.launcher.Main.ExitState) ErrorCollector(com.redhat.ceylon.compiler.java.test.ErrorCollector) CompilerError(com.redhat.ceylon.compiler.java.test.CompilerError) CeyloncTaskImpl(com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl) Test(org.junit.Test)

Example 32 with CeyloncTaskImpl

use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.

the class IssuesTests_1500_1999 method testBug1830.

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

Example 33 with CeyloncTaskImpl

use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.

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);
}
Also used : ExitState(com.redhat.ceylon.compiler.java.launcher.Main.ExitState) ErrorCollector(com.redhat.ceylon.compiler.java.test.ErrorCollector) CeyloncTaskImpl(com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl) Test(org.junit.Test)

Example 34 with CeyloncTaskImpl

use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.

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(com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 35 with CeyloncTaskImpl

use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.

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(com.redhat.ceylon.compiler.java.tools.CeyloncTool) CeyloncTaskImpl(com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl) File(java.io.File) CeyloncFileManager(com.redhat.ceylon.compiler.java.tools.CeyloncFileManager) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

CeyloncTaskImpl (com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl)53 Test (org.junit.Test)43 File (java.io.File)27 JarFile (java.util.jar.JarFile)19 ErrorCollector (com.redhat.ceylon.compiler.java.test.ErrorCollector)18 LinkedList (java.util.LinkedList)18 ZipEntry (java.util.zip.ZipEntry)13 CompilerError (com.redhat.ceylon.compiler.java.test.CompilerError)11 ZipFile (java.util.zip.ZipFile)8 ExitState (com.redhat.ceylon.compiler.java.launcher.Main.ExitState)6 CeyloncFileManager (com.redhat.ceylon.compiler.java.tools.CeyloncFileManager)5 CeyloncTool (com.redhat.ceylon.compiler.java.tools.CeyloncTool)5 ArrayList (java.util.ArrayList)5 TaskEvent (com.sun.source.util.TaskEvent)4 TaskListener (com.sun.source.util.TaskListener)4 Module (com.redhat.ceylon.model.typechecker.model.Module)3 JCCompilationUnit (com.sun.tools.javac.tree.JCTree.JCCompilationUnit)3 DiagnosticListener (javax.tools.DiagnosticListener)3 Ignore (org.junit.Ignore)3 JavaPositionsRetriever (com.redhat.ceylon.compiler.java.codegen.JavaPositionsRetriever)2