Search in sources :

Example 6 with CompilerError

use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.

the class CMRTests method testMdlBug1062IncompatibleSharedImport.

@Test
public void testMdlBug1062IncompatibleSharedImport() throws IOException {
    // compile our java class
    File classesOutputFolder = new File(destDir + "-jar-classes");
    cleanCars(classesOutputFolder.getPath());
    classesOutputFolder.mkdirs();
    File jarOutputFolder = new File(destDir + "-jar");
    cleanCars(jarOutputFolder.getPath());
    jarOutputFolder.mkdirs();
    compileJavaModule(jarOutputFolder, classesOutputFolder, "bug1062.javaA", "1", new File(getPackagePath() + "/modules/bug1062/javaA1-src"), new File[0], "bug1062/javaA/JavaA.java");
    compileJavaModule(jarOutputFolder, classesOutputFolder, "bug1062.javaA", "2", new File(getPackagePath() + "/modules/bug1062/javaA2-src"), new File[0], "bug1062/javaA/JavaA.java");
    compileJavaModule(jarOutputFolder, classesOutputFolder, "bug1062.javaB", "1", new File(getPackagePath() + "/modules/bug1062/javaB-module-export-src"), new File[] { new File(jarOutputFolder, "bug1062/javaA/1/bug1062.javaA-1.jar") }, "bug1062/javaB/JavaB.java");
    // ceylon module imports JavaA/2 and JavaB/1
    // JavaB/1 shared imports JavaA/1
    assertErrors("modules/bug1062/ceylon/test", Arrays.asList("-rep", jarOutputFolder.getPath()), null, new CompilerError(2, "source code imports two different versions of module 'bug1062.javaA': version '1' and version '2'"));
}
Also used : CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) JarFile(java.util.jar.JarFile) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test)

Example 7 with CompilerError

use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.

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, "all-lowercase ASCII module names are recommended"), 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'"));
}
Also used : ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) Test(org.junit.Test)

Example 8 with CompilerError

use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.

the class CMRTests method testMdlDefaultUsesJavaWithoutImportingIt.

@Test
public void testMdlDefaultUsesJavaWithoutImportingIt() throws IOException {
    List<String> options = new LinkedList<String>();
    options.add("-src");
    options.add(getPackagePath() + "/modules/jdk/defaultUsesJavaWithoutImportingIt");
    options.addAll(defaultOptions);
    assertErrors("modules/jdk/defaultUsesJavaWithoutImportingIt/Foo", new CompilerError(20, "package not found in imported modules: 'java.lang' (define a module and add module import to its module descriptor)"), new CompilerError(23, "function or value is not defined: 'nanoTime' might be misspelled or is not imported"));
}
Also used : CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 9 with CompilerError

use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.

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(org.eclipse.ceylon.compiler.java.test.ErrorCollector) CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) Test(org.junit.Test)

Example 10 with CompilerError

use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.

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, "source code imports two different versions of module 'a': version '1' and version '2'"));
}
Also used : ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) Test(org.junit.Test)

Aggregations

CompilerError (org.eclipse.ceylon.compiler.java.test.CompilerError)55 Test (org.junit.Test)54 ErrorCollector (org.eclipse.ceylon.compiler.java.test.ErrorCollector)19 File (java.io.File)15 CeyloncTaskImpl (org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl)12 JarFile (java.util.jar.JarFile)11 ZipEntry (java.util.zip.ZipEntry)8 LinkedList (java.util.LinkedList)7 ZipFile (java.util.zip.ZipFile)5 FileInputStream (java.io.FileInputStream)2 FileOutputStream (java.io.FileOutputStream)2 JarOutputStream (java.util.jar.JarOutputStream)2 ExitState (org.eclipse.ceylon.compiler.java.launcher.Main.ExitState)2 CompilationTask (org.eclipse.ceylon.javax.tools.JavaCompiler.CompilationTask)2 Ignore (org.junit.Ignore)2 HttpServer (com.sun.net.httpserver.HttpServer)1 FileWriter (java.io.FileWriter)1 Writer (java.io.Writer)1 TreeSet (java.util.TreeSet)1 JarEntry (java.util.jar.JarEntry)1