Search in sources :

Example 16 with ErrorCollector

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

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

Example 17 with ErrorCollector

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

the class MiscTests method compileSDKOnly.

private void compileSDKOnly(String[] modules, String[] extraModules) {
    String sourceDir = "../../ceylon-sdk/source";
    // don't run this if the SDK is not checked out
    File sdkFile = new File(sourceDir);
    if (!sdkFile.exists())
        return;
    java.util.List<String> moduleNames = new ArrayList<String>(modules.length);
    for (String module : modules) {
        moduleNames.add("ceylon." + module);
    }
    for (String module : extraModules) {
        moduleNames.add(module);
    }
    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;
    }
    ErrorCollector errorCollector = new ErrorCollector();
    CeyloncFileManager fileManager = (CeyloncFileManager) compiler.getStandardFileManager(null, null, null);
    CeyloncTaskImpl task = (CeyloncTaskImpl) compiler.getTask(null, fileManager, errorCollector, Arrays.asList("-sourcepath", sourceDir, "-d", "build/classes-sdk", "-sysrep", getSysRepPath(), "-suppress-warnings", "ceylonNamespace", "-cp", getClassPathAsPath()), moduleNames, null);
    Boolean result = task.call();
    Assert.assertEquals("Compilation of SDK itself failed: " + errorCollector.getAssertionFailureMessage(), Boolean.TRUE, result);
}
Also used : ArrayList(java.util.ArrayList) CeyloncTool(org.eclipse.ceylon.compiler.java.tools.CeyloncTool) ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) File(java.io.File) CeyloncFileManager(org.eclipse.ceylon.compiler.java.tools.CeyloncFileManager)

Example 18 with ErrorCollector

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

the class RecoveryTests method testTako.

@Ignore("This test largely depends on modules that are now binary-incompatible")
@Test
public void testTako() throws IOException {
    String subPath = "modules/bug1411";
    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, subPath + "/dupdecl.ceylon", subPath + "/moduletest1/module.ceylon", subPath + "/moduletest1/package.ceylon", subPath + "/moduletest1/helloworld.ceylon", subPath + "/hello/hello.ceylon", subPath + "/hello/module.ceylon", subPath + "/hello/package.ceylon", subPath + "/testtest/module.ceylon", subPath + "/testtest/test.ceylon", subPath + "/sub/mod/module.ceylon", subPath + "/sub/mod/run.ceylon", subPath + "/sub/mod/package.ceylon", subPath + "/unknownmodule/module.ceylon", subPath + "/unknownmodule/run.ceylon", subPath + "/unknownmodule/package.ceylon", subPath + "/interop/module.ceylon", subPath + "/interop/interop.ceylon", subPath + "/jsonly/jsonly.ceylon", subPath + "/jsonly/module.ceylon", subPath + "/jsonly/package.ceylon", subPath + "/modulep/module.ceylon", subPath + "/modulep/main.ceylon", subPath + "/browser/dom/main.ceylon", subPath + "/browser/dom/package.ceylon", subPath + "/browser/module.ceylon", subPath + "/browser/main.ceylon", subPath + "/browser/package.ceylon", subPath + "/test/InheritanceAndBoxingTest.ceylon", subPath + "/test/ExceptionTest.ceylon", subPath + "/test/Foo.ceylon", subPath + "/test/GameOfLife.ceylon", subPath + "/test/Bar.ceylon", subPath + "/test/encoding.ceylon", subPath + "/test/helloworld.ceylon", subPath + "/swing/module.ceylon", subPath + "/swing/run.ceylon", subPath + "/swing/package.ceylon", subPath + "/interoprev/module.ceylon", subPath + "/interoprev/run.ceylon", subPath + "/interoprev/package.ceylon", subPath + "/java/hello.ceylon", subPath + "/java/module.ceylon", subPath + "/java/package.ceylon", subPath + "/helloworld.ceylon", subPath + "/wrongversion/module.ceylon", subPath + "/wrongversion/run.ceylon", subPath + "/wrongversion/package.ceylon", subPath + "/importhello/module.ceylon", subPath + "/importhello/helloworld.ceylon", subPath + "/usingimport.ceylon", // subPath + "/javaa/run.ceylon"
    subPath + "/gavinprob/module.ceylon", subPath + "/gavinprob/main.ceylon", subPath + "/web_ide_script/module.ceylon", subPath + "/web_ide_script/hello_world.ceylon", subPath + "/timetest/module.ceylon", subPath + "/timetest/test.ceylon");
    Boolean ret = task.call();
    assertFalse(ret);
    TreeSet<CompilerError> actualErrors = c.get(Diagnostic.Kind.ERROR);
    compareErrors(actualErrors, new CompilerError(1, "package not found in imported modules: 'java.lang' (define a module and add module import to its module descriptor)"), new CompilerError(2, "source code imports two different versions of module 'ceylon.file': version '0.5' and version '1.1.0'"), new CompilerError(2, "cannot find module artifact 'fooxhilio.bastardo-77.9(.car|.jar)'\n" + "  \t- dependency tree: 'unknownmodule/1.0.0' -> 'fooxhilio.bastardo/77.9'"), new CompilerError(4, "function or value is not defined: 'nanoTime' might be misspelled or is not imported"), new CompilerError(4, "type does not exist: 'Test'"), new CompilerError(4, "unsupported module name: this namespace is used by Java platform modules"), new CompilerError(5, "duplicate declaration name: 'run'"), new CompilerError(7, "duplicate declaration name: 'run'"), new CompilerError(10, "case must be a toplevel anonymous class: 'alive' is not toplevel"), new CompilerError(10, "case must be a toplevel anonymous class: 'dead' is not toplevel"), new CompilerError(10, "case must be a toplevel anonymous class: 'moribund' is not toplevel"), new CompilerError(10, "case must be a toplevel anonymous class: 'resurrected' is not toplevel"), new CompilerError(12, "imported declaration not found: 'newServer_bogus'"), new CompilerError(30, "function or value is not defined: 'newServer_bogus' might be misspelled or is not imported"), new CompilerError(135, "function or value is not defined: 'array' might be misspelled or is not imported"), new CompilerError(138, "could not determine type of function or value reference: 'cells'"), new CompilerError(139, "could not determine type of function or value reference: 'c'"), new CompilerError(140, "could not determine type of function or value reference: 'c'"));
    File carFile = getModuleArchive("default", null);
    assertTrue(carFile.exists());
    String[] modules = new String[] { "swing/1.0.0", "web_ide_script/1.0.0", "browser/1.0.0", "timetest/1.0.0", "interop/1.0.0", "importhello/0.1", "interoprev/1.0.0", "modulep/0.1", "hello/1.0.0", "moduletest1/0.1", "jsonly/1.0.0", "testtest/1.1", "sub.mod/1.0.0" };
    for (String module : modules) {
        int sep = module.indexOf('/');
        String name = module.substring(0, sep);
        String version = module.substring(sep + 1);
        carFile = getModuleArchive(name, version);
        assertTrue("Module created car: " + module, carFile.exists());
    }
}
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) JarFile(java.util.jar.JarFile) File(java.io.File) LinkedList(java.util.LinkedList) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 19 with ErrorCollector

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

the class RecoveryTests method testErrorSameCompilationUnit.

@Test
public void testErrorSameCompilationUnit() throws IOException {
    String subPath = "modules/errorInSameCompilationUnit";
    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, subPath + "/someok.ceylon");
    Boolean ret = task.call();
    assertFalse(ret);
    TreeSet<CompilerError> actualErrors = c.get(Diagnostic.Kind.ERROR);
    compareErrors(actualErrors, new CompilerError(23, "type is not defined: 'ERROR' might be misspelled or is not imported"));
    File carFile = getModuleArchive("default", null);
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    ZipEntry moduleClass = car.getEntry("a_.class");
    assertNotNull(moduleClass);
    car.close();
}
Also used : ZipEntry(java.util.zip.ZipEntry) ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) CeyloncTaskImpl(org.eclipse.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)

Example 20 with ErrorCollector

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

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: the name 'run' is not unique in this scope"));
    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(org.eclipse.ceylon.compiler.java.test.ErrorCollector) CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) CeyloncTaskImpl(org.eclipse.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 (org.eclipse.ceylon.compiler.java.test.ErrorCollector)35 Test (org.junit.Test)31 CeyloncTaskImpl (org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl)23 CompilerError (org.eclipse.ceylon.compiler.java.test.CompilerError)19 File (java.io.File)16 JarFile (java.util.jar.JarFile)12 LinkedList (java.util.LinkedList)11 ZipEntry (java.util.zip.ZipEntry)7 ArrayList (java.util.ArrayList)4 ExitState (org.eclipse.ceylon.compiler.java.launcher.Main.ExitState)4 Set (java.util.Set)3 ZipFile (java.util.zip.ZipFile)3 CeyloncFileManager (org.eclipse.ceylon.compiler.java.tools.CeyloncFileManager)3 CeyloncTool (org.eclipse.ceylon.compiler.java.tools.CeyloncTool)3 Module (org.eclipse.ceylon.model.typechecker.model.Module)3 Ignore (org.junit.Ignore)3 JarEntry (java.util.jar.JarEntry)2 Manifest (java.util.jar.Manifest)2 StringWriter (java.io.StringWriter)1 TreeSet (java.util.TreeSet)1