Search in sources :

Example 26 with ErrorCollector

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

the class RecoveryTests method testDuplicateInDefault.

@Test
public void testDuplicateInDefault() throws IOException {
    String subPath = "modules/duplicateInDefault";
    String srcPath = getPackagePath() + subPath;
    List<String> options = new LinkedList<String>();
    options.add("-src");
    options.add(srcPath);
    options.addAll(defaultOptions);
    options.add("-continue");
    ErrorCollector c = new ErrorCollector();
    CeyloncTaskImpl task = getCompilerTask(options, c, Arrays.asList("okmodule"), subPath + "/dupdeclerr1.ceylon", subPath + "/dupdeclerr2.ceylon", subPath + "/someok.ceylon");
    Boolean ret = task.call();
    assertFalse(ret);
    TreeSet<CompilerError> actualErrors = c.get(Diagnostic.Kind.ERROR);
    compareErrors(actualErrors, // new CompilerError(21, "cannot find module artifact notfound-1(.car|.jar)\n  \t- dependency tree: okmodule/1.0.0 -> notfound/1"),
    new CompilerError(20, "duplicate declaration name: 'run'"));
    File carFile = getModuleArchive("default", null);
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    ZipEntry moduleClass = car.getEntry("foobar_.class");
    assertNotNull(moduleClass);
    car.close();
    carFile = getModuleArchive("okmodule", "1.0.0");
    assertTrue(carFile.exists());
    car = new JarFile(carFile);
    moduleClass = car.getEntry("okmodule/$module_.class");
    assertNotNull(moduleClass);
    car.close();
}
Also used : ZipEntry(java.util.zip.ZipEntry) ErrorCollector(com.redhat.ceylon.compiler.java.test.ErrorCollector) CompilerError(com.redhat.ceylon.compiler.java.test.CompilerError) CeyloncTaskImpl(com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl) JarFile(java.util.jar.JarFile) JarFile(java.util.jar.JarFile) File(java.io.File) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

ErrorCollector (com.redhat.ceylon.compiler.java.test.ErrorCollector)26 Test (org.junit.Test)23 CeyloncTaskImpl (com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl)18 CompilerError (com.redhat.ceylon.compiler.java.test.CompilerError)15 File (java.io.File)10 JarFile (java.util.jar.JarFile)7 LinkedList (java.util.LinkedList)6 ZipEntry (java.util.zip.ZipEntry)6 ArrayList (java.util.ArrayList)4 ExitState (com.redhat.ceylon.compiler.java.launcher.Main.ExitState)3 CeyloncFileManager (com.redhat.ceylon.compiler.java.tools.CeyloncFileManager)3 CeyloncTool (com.redhat.ceylon.compiler.java.tools.CeyloncTool)3 Module (com.redhat.ceylon.model.typechecker.model.Module)3 ZipFile (java.util.zip.ZipFile)2 Ignore (org.junit.Ignore)2 ModuleImport (com.redhat.ceylon.model.typechecker.model.ModuleImport)1 StringWriter (java.io.StringWriter)1