Search in sources :

Example 11 with ErrorCollector

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

the class CMRTests method testOverridesCeylonModuleVersionAlterdPackageSharing.

@Test
public void testOverridesCeylonModuleVersionAlterdPackageSharing() {
    setupBinaryModulesForOverridesCeylonModuleTests();
    ErrorCollector collector = new ErrorCollector();
    CeyloncTaskImpl compilerTask = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules", "-overrides", getPackagePath() + "modules/overridesCeylonModule/overrides-b-version.xml"), collector, "modules/overridesCeylonModule/module.ceylon", "modules/overridesCeylonModule/testImportHiddenPackage.ceylon");
    ModulesRetriever modulesRetriever = new ModulesRetriever(compilerTask.getContext());
    compilerTask.setTaskListener(modulesRetriever);
    Boolean result = compilerTask.call();
    Assert.assertEquals(Boolean.FALSE, result);
    compareErrors(collector.get(Diagnostic.Kind.ERROR), new CompilerError(2, "imported package is not visible: package 'b.hidden' is not shared by module 'b'"));
}
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 12 with ErrorCollector

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

the class CMRTests method testMdlNoPomManifest.

@Test
public void testMdlNoPomManifest() throws IOException {
    ErrorCollector c = new ErrorCollector();
    assertCompilesOk(c, getCompilerTask(Arrays.asList("-nopom", "-out", destDir), c, "modules/pom/a/module.ceylon", "modules/pom/b/module.ceylon").call2());
    final String moduleName = "org.eclipse.ceylon.compiler.java.test.cmr.modules.pom.b";
    final String moduleVersion = "1";
    File carFile = getModuleArchive(moduleName, moduleVersion);
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    ZipEntry pomFile = car.getEntry("META-INF/maven/org.eclipse.ceylon.compiler.java.test.cmr.modules.pom/b/pom.xml");
    assertNull(pomFile);
    ZipEntry propertiesFile = car.getEntry("META-INF/maven/org.eclipse.ceylon.compiler.java.test.cmr.modules.pom/b/pom.properties");
    assertNull(propertiesFile);
    car.close();
}
Also used : ZipEntry(java.util.zip.ZipEntry) ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) JarFile(java.util.jar.JarFile) JarFile(java.util.jar.JarFile) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test)

Example 13 with ErrorCollector

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

the class IssuesTests_1000_1499 method testBug1347.

@Test
public void testBug1347() {
    Assume.assumeTrue("Runs on JDK8", JDKUtils.jdk == JDKUtils.JDK.JDK8);
    assertErrors("bug13xx/bug1347/bug1347", Arrays.asList("-out", destDir, "-rep", "test/java8/modules"), null, new CompilerError(12, "call to a static interface member is not allowed unless you set the -target flag to 8: --javac=-target=8"), new CompilerError(14, "call to a static interface member is not allowed unless you set the -target flag to 8: --javac=-target=8"), new CompilerError(16, "call to a static interface member is not allowed unless you set the -target flag to 8: --javac=-target=8"), new CompilerError(28, "call to a static interface member is not allowed unless you set the -target flag to 8: --javac=-target=8"), new CompilerError(30, "call to a static interface member is not allowed unless you set the -target flag to 8: --javac=-target=8"));
    ErrorCollector c = new ErrorCollector();
    assertCompilesOk(c, getCompilerTask(Arrays.asList("-target", "8", "-out", destDir, "-rep", "test/java8/modules"), c, "bug13xx/bug1347/bug1347.ceylon").call2());
    run("org.eclipse.ceylon.compiler.java.test.issues.bug13xx.bug1347.test", new ModuleWithArtifact("org.eclipse.ceylon.compiler.java.test.issues.bug13xx.bug1347", "1"), new ModuleWithArtifact("com.ceylon.java8", "1", "test/java8/modules", "jar"));
}
Also used : CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) Test(org.junit.Test)

Example 14 with ErrorCollector

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

the class IssuesTests_1500_1999 method testBug1631.

@Ignore("Used for benchmarking")
@Test
public void testBug1631() throws Exception {
    // System.err.println("Press enter to continue");
    // System.in.read();
    // System.err.println("Let's go");
    long totals = 0;
    int runs = 1;
    for (int i = 0; i < runs; i++) {
        long start = System.nanoTime();
        ErrorCollector c = new ErrorCollector();
        assertCompilesOk(c, getCompilerTask(Arrays.asList(/*"-verbose:benchmark", */
        "-out", destDir), c, "bug16xx/bug1631/run.ceylon").call2());
        // benchmarkParse("bug16xx/bug1631/run.ceylon");
        long end = System.nanoTime();
        long total = end - start;
        System.err.println("Took " + (total / 1_000_000) + "ms");
        totals += total;
    }
    System.err.println("Average " + ((totals / 1_000_000) / runs) + "ms");
// System.err.println("Press enter to quit");
// System.in.read();
// System.err.println("Done");
}
Also used : ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 15 with ErrorCollector

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

the class IssuesTests_1500_1999 method testBug1830.

@Test
public void testBug1830() {
    ErrorCollector collector = new ErrorCollector();
    CeyloncTaskImpl task = getCompilerTask(defaultOptions, collector, "bug18xx/Bug1830.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)

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