Search in sources :

Example 16 with CeyloncTaskImpl

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

the class CMRTests method testMdlAetherMissingDependencies.

@Test
public void testMdlAetherMissingDependencies() throws IOException {
    CompilerError[] expectedErrors = new CompilerError[] { new CompilerError(6, "Error while loading the org.apache.camel:camel-jetty/2.9.4 module:\n" + "   Declaration 'org.apache.camel.component.http.HttpComponent' could not be found in module 'org.apache.camel:camel-jetty' or its imported modules"), new CompilerError(10, "argument must be assignable to parameter 'arg1' of 'addComponent' in 'DefaultCamelContext': 'JettyHttpComponent' is not assignable to 'Component?': Error while loading the org.apache.camel:camel-jetty/2.9.4 module:\n" + "   Declaration 'org.apache.camel.component.http.HttpComponent' could not be found in module 'org.apache.camel:camel-jetty' or its imported modules") };
    ErrorCollector collector = new ErrorCollector();
    // Try to compile the ceylon module
    CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir, "-rep", "aether"), collector, "modules/bug1100/module.ceylon", "modules/bug1100/test.ceylon");
    assertEquals("Compilation failed", Boolean.FALSE, ceylonTask.call());
    TreeSet<CompilerError> actualErrors = collector.get(Diagnostic.Kind.ERROR);
    compareErrors(actualErrors, expectedErrors);
}
Also used : CompilerError(com.redhat.ceylon.compiler.java.test.CompilerError) ErrorCollector(com.redhat.ceylon.compiler.java.test.ErrorCollector) CeyloncTaskImpl(com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl) Test(org.junit.Test)

Example 17 with CeyloncTaskImpl

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

the class CMRTests method testMdlCeylonAetherDependencyConflict.

@Test
public void testMdlCeylonAetherDependencyConflict() throws IOException {
    // Try to compile the ceylon module
    CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir, "-verbose:cmr"), (DiagnosticListener<? super FileObject>) null, "modules/ceylonAetherConflict2/module.ceylon");
    assertEquals(Boolean.TRUE, ceylonTask.call());
    ErrorCollector collector = new ErrorCollector();
    ceylonTask = getCompilerTask(Arrays.asList("-out", destDir, "-verbose:cmr"), collector, "modules/ceylonAetherConflict/module.ceylon", "modules/ceylonAetherConflict/foo.ceylon");
    assertEquals(Boolean.TRUE, ceylonTask.call());
    compareErrors(collector.get(Diagnostic.Kind.WARNING), new CompilerError(Diagnostic.Kind.WARNING, null, 21, "source code imports two different versions of similar modules 'org.apache.httpcomponents.httpclient/4.3.2' and 'org.apache.httpcomponents:httpclient/4.3.3'"), new CompilerError(Diagnostic.Kind.WARNING, null, 21, "module (transitively) imports conflicting versions of similar dependencies 'org.apache.httpcomponents.httpclient/4.3.2' and 'org.apache.httpcomponents:httpclient/4.3.3'"));
}
Also used : 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 18 with CeyloncTaskImpl

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

the class CMRTests method testMdlCompilerGeneratesModuleForValidUnits.

@Test
public void testMdlCompilerGeneratesModuleForValidUnits() throws IOException {
    CeyloncTaskImpl compilerTask = getCompilerTask("modules/single/module.ceylon", "modules/single/Correct.ceylon", "modules/single/Invalid.ceylon");
    Boolean success = compilerTask.call();
    assertFalse(success);
    File carFile = getModuleArchive("com.redhat.ceylon.compiler.java.test.cmr.modules.single", "6.6.6");
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    ZipEntry moduleClass = car.getEntry("com/redhat/ceylon/compiler/java/test/cmr/modules/single/$module_.class");
    assertNotNull(moduleClass);
    ZipEntry correctClass = car.getEntry("com/redhat/ceylon/compiler/java/test/cmr/modules/single/Correct.class");
    assertNotNull(correctClass);
    ZipEntry invalidClass = car.getEntry("com/redhat/ceylon/compiler/java/test/cmr/modules/single/Invalid.class");
    assertNull(invalidClass);
    car.close();
}
Also used : ZipEntry(java.util.zip.ZipEntry) CeyloncTaskImpl(com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl) JarFile(java.util.jar.JarFile) JarFile(java.util.jar.JarFile) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test)

Example 19 with CeyloncTaskImpl

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

the class CMRTests method testMdlCeylonAetherDuplicateImports.

@Test
public void testMdlCeylonAetherDuplicateImports() throws IOException {
    // Try to compile the ceylon module
    ErrorCollector collector = new ErrorCollector();
    CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir, "-verbose:cmr"), collector, "modules/ceylonAetherDuplicateImports/module.ceylon", "modules/ceylonAetherDuplicateImports/foo.ceylon");
    assertEquals(Boolean.FALSE, ceylonTask.call());
    compareErrors(collector.get(Diagnostic.Kind.ERROR), new CompilerError(23, "duplicate module import: 'org.apache.httpcomponents.httpclient'"), new CompilerError(25, "duplicate module import: 'org.apache.httpcomponents:httpclient'"));
}
Also used : 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 20 with CeyloncTaskImpl

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

the class CMRTests method testMdlDependenciesFromMavenAutoExport.

@Test
public void testMdlDependenciesFromMavenAutoExport() throws Throwable {
    Assume.assumeTrue("Runs on JDK8", JDKUtils.jdk == JDKUtils.JDK.JDK8);
    CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir), "modules/sparkframework/module.ceylon", "modules/sparkframework/test.ceylon");
    assertEquals("Compilation failed", Boolean.TRUE, ceylonTask.call());
    runInJBossModules("run", "com.redhat.ceylon.compiler.java.test.cmr.modules.sparkframework/1", Arrays.asList("--auto-export-maven-dependencies"));
}
Also used : CeyloncTaskImpl(com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl) 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