Search in sources :

Example 11 with CompilerError

use of com.redhat.ceylon.compiler.java.test.CompilerError 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 12 with CompilerError

use of com.redhat.ceylon.compiler.java.test.CompilerError in project ceylon-compiler by ceylon.

the class CMRTests method testMdlMultipleVersionsDuringImplicitImport.

@Test
public void testMdlMultipleVersionsDuringImplicitImport() {
    // Compile module A/1
    Boolean result = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules/multiversion/a1"), "modules/multiversion/a1/a/module.ceylon", "modules/multiversion/a1/a/package.ceylon", "modules/multiversion/a1/a/A.ceylon").call();
    Assert.assertEquals(Boolean.TRUE, result);
    // Compile module A/2
    result = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules/multiversion/a2"), "modules/multiversion/a2/a/module.ceylon", "modules/multiversion/a2/a/package.ceylon", "modules/multiversion/a2/a/A.ceylon").call();
    Assert.assertEquals(Boolean.TRUE, result);
    // Compile module bExportsA1/1
    result = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules/multiversion/b"), "modules/multiversion/b/bExportsA1/module.ceylon", "modules/multiversion/b/bExportsA1/package.ceylon", "modules/multiversion/b/bExportsA1/B.ceylon").call();
    Assert.assertEquals(Boolean.TRUE, result);
    // Compile module cImportsABIndirectlyFail which imports both A/1 and A/2
    ErrorCollector collector = new ErrorCollector();
    result = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules/multiversion/c"), collector, "modules/multiversion/c/cImportsABIndirectlyFail/module.ceylon", "modules/multiversion/c/cImportsABIndirectlyFail/C.ceylon").call();
    Assert.assertEquals(Boolean.FALSE, result);
    compareErrors(collector.get(Diagnostic.Kind.ERROR), new CompilerError(20, "module (transitively) imports conflicting versions of dependency 'a': version '1' and version '2'"), new CompilerError(20, "source code imports two different versions of module 'a': version '1' and version '2'"));
}
Also used : ErrorCollector(com.redhat.ceylon.compiler.java.test.ErrorCollector) CompilerError(com.redhat.ceylon.compiler.java.test.CompilerError) Test(org.junit.Test)

Example 13 with CompilerError

use of com.redhat.ceylon.compiler.java.test.CompilerError 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 14 with CompilerError

use of com.redhat.ceylon.compiler.java.test.CompilerError in project ceylon-compiler by ceylon.

the class CMRTests method testMdlCarWithInvalidSHA1.

@Test
public void testMdlCarWithInvalidSHA1() throws IOException {
    compile("modules/single/module.ceylon");
    File carFile = getModuleArchive("com.redhat.ceylon.compiler.java.test.cmr.modules.single", "6.6.6");
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    // just to be sure
    ZipEntry moduleClass = car.getEntry("com/redhat/ceylon/compiler/java/test/cmr/modules/single/$module_.class");
    assertNotNull(moduleClass);
    car.close();
    // now let's break the SHA1
    File shaFile = getArchiveName("com.redhat.ceylon.compiler.java.test.cmr.modules.single", "6.6.6", destDir, "car.sha1");
    Writer w = new FileWriter(shaFile);
    w.write("fubar");
    w.flush();
    w.close();
    // now try to compile the subpackage with a broken SHA1
    String carName = "/com/redhat/ceylon/compiler/java/test/cmr/modules/single/6.6.6/com.redhat.ceylon.compiler.java.test.cmr.modules.single-6.6.6.car";
    carName = carName.replace('/', File.separatorChar);
    assertErrors("modules/single/subpackage/Subpackage", new CompilerError(-1, "Module car " + carName + " obtained from repository " + (new File(destDir).getAbsolutePath()) + " has an invalid SHA1 signature: you need to remove it and rebuild the archive, since it may be corrupted."));
}
Also used : ZipEntry(java.util.zip.ZipEntry) FileWriter(java.io.FileWriter) CompilerError(com.redhat.ceylon.compiler.java.test.CompilerError) JarFile(java.util.jar.JarFile) JarFile(java.util.jar.JarFile) ZipFile(java.util.zip.ZipFile) File(java.io.File) Writer(java.io.Writer) FileWriter(java.io.FileWriter) Test(org.junit.Test)

Example 15 with CompilerError

use of com.redhat.ceylon.compiler.java.test.CompilerError in project ceylon-compiler by ceylon.

the class CMRTests method testMdlMultipleVersionsOnSameCompilation.

@Test
public void testMdlMultipleVersionsOnSameCompilation() {
    // Compile module A/1
    Boolean result = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules/multiversion/a1"), "modules/multiversion/a1/a/module.ceylon", "modules/multiversion/a1/a/package.ceylon", "modules/multiversion/a1/a/A.ceylon").call();
    Assert.assertEquals(Boolean.TRUE, result);
    ErrorCollector collector = new ErrorCollector();
    // Compile module A/2 with B importing A/1
    result = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules/multiversion/a2" + File.pathSeparator + getPackagePath() + "/modules/multiversion/b"), collector, "modules/multiversion/a2/a/module.ceylon", "modules/multiversion/a2/a/package.ceylon", "modules/multiversion/a2/a/A.ceylon", "modules/multiversion/b/b/module.ceylon", "modules/multiversion/b/b/B.ceylon").call();
    Assert.assertEquals(Boolean.FALSE, result);
    compareErrors(collector.get(Diagnostic.Kind.ERROR), new CompilerError(20, "source code imports two different versions of module 'a': version '1' and version '2'"));
}
Also used : ErrorCollector(com.redhat.ceylon.compiler.java.test.ErrorCollector) CompilerError(com.redhat.ceylon.compiler.java.test.CompilerError) Test(org.junit.Test)

Aggregations

CompilerError (com.redhat.ceylon.compiler.java.test.CompilerError)47 Test (org.junit.Test)47 ErrorCollector (com.redhat.ceylon.compiler.java.test.ErrorCollector)15 File (java.io.File)13 CeyloncTaskImpl (com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl)11 JarFile (java.util.jar.JarFile)11 ZipEntry (java.util.zip.ZipEntry)7 LinkedList (java.util.LinkedList)6 ZipFile (java.util.zip.ZipFile)4 HttpServer (com.sun.net.httpserver.HttpServer)2 FileInputStream (java.io.FileInputStream)2 FileOutputStream (java.io.FileOutputStream)2 JarOutputStream (java.util.jar.JarOutputStream)2 CompilationTask (javax.tools.JavaCompiler.CompilationTask)2 ExitState (com.redhat.ceylon.compiler.java.launcher.Main.ExitState)1 Module (com.redhat.ceylon.model.typechecker.model.Module)1 FileWriter (java.io.FileWriter)1 Writer (java.io.Writer)1 Ignore (org.junit.Ignore)1