Search in sources :

Example 41 with CeyloncTaskImpl

use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.

the class IssuesTests_1500_1999 method testBug1773.

@Test
public void testBug1773() {
    ErrorCollector collector = new ErrorCollector();
    CeyloncTaskImpl task = getCompilerTask(defaultOptions, collector, "bug17xx/Bug1773.ceylon");
    // now compile it all the way
    ExitState exitState = task.call2();
    Assert.assertEquals(ExitState.CeylonState.ERROR, exitState.ceylonState);
    // make sure we only got one, do not trust actualErrors.size() for that since it's a Set so
    // two methods with same contents would count as one.
    Assert.assertEquals(1, exitState.errorCount);
    TreeSet<CompilerError> actualErrors = collector.get(Diagnostic.Kind.ERROR);
    compareErrors(actualErrors, new CompilerError(22, "dynamic is not supported on the JVM"));
}
Also used : ExitState(org.eclipse.ceylon.compiler.java.launcher.Main.ExitState) 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 42 with CeyloncTaskImpl

use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.

the class MiscTests method compileSDKTests.

private void compileSDKTests(String[] modules, String[] extraModules) {
    String sourceDir = "../../ceylon-sdk/test-source";
    String depsDir = "../../ceylon-sdk/test-deps";
    // 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) {
        String name = "test.ceylon." + module;
        // only add it if it exists
        if (new File(sourceDir, name.replace('.', File.separatorChar)).isDirectory())
            moduleNames.add(name);
    }
    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, "-sysrep", getSysRepPath(), "-rep", depsDir, "-d", "build/classes-sdk", "-cp", getClassPathAsPath()), moduleNames, null);
    Boolean result = task.call();
    Assert.assertEquals("Compilation of SDK tests 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 43 with CeyloncTaskImpl

use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.

the class CMRTests method compileModuleFromSourceFolder.

private void compileModuleFromSourceFolder(String module, String srcFolder, String outFolder, String... repos) {
    List<String> options = new LinkedList<String>();
    options.add("-src");
    options.add(getPackagePath() + "/modules/" + srcFolder);
    if (outFolder != null) {
        options.add("-out");
        options.add(outFolder);
    } else {
        options.addAll(defaultOptions);
    }
    for (String repo : repos) {
        options.add("-rep");
        options.add(repo);
    }
    CeyloncTaskImpl task = getCompilerTask(options, null, Arrays.asList(module));
    Boolean ret = task.call();
    assertTrue(ret);
}
Also used : CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) LinkedList(java.util.LinkedList)

Example 44 with CeyloncTaskImpl

use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.

the class CMRTests method testMdlCompilerGeneratesModuleForValidUnits.

@Test
public void testMdlCompilerGeneratesModuleForValidUnits() throws IOException {
    CeyloncTaskImpl compilerTask = getCompilerTask("modules/single/module.ceylon", "modules/single/Correct.ceylon", "modules/single/Invalid.ceylon");
    Boolean success = compilerTask.call();
    assertFalse(success);
    File carFile = getModuleArchive("org.eclipse.ceylon.compiler.java.test.cmr.modules.single", "6.6.6");
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    ZipEntry moduleClass = car.getEntry("org/eclipse/ceylon/compiler/java/test/cmr/modules/single/$module_.class");
    assertNotNull(moduleClass);
    ZipEntry correctClass = car.getEntry("org/eclipse/ceylon/compiler/java/test/cmr/modules/single/Correct.class");
    assertNotNull(correctClass);
    ZipEntry invalidClass = car.getEntry("org/eclipse/ceylon/compiler/java/test/cmr/modules/single/Invalid.class");
    assertNull(invalidClass);
    car.close();
}
Also used : ZipEntry(java.util.zip.ZipEntry) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) JarFile(java.util.jar.JarFile) JarFile(java.util.jar.JarFile) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test)

Example 45 with CeyloncTaskImpl

use of org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon by eclipse.

the class CMRTests method testMdlAetherMissingDependenciesOverride.

@Test
public void testMdlAetherMissingDependenciesOverride() throws IOException {
    // Try to compile the ceylon module
    CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir, "-rep", "aether", "-overrides", getPackagePath() + "/modules/bug1100/overrides.xml"), "modules/bug1100/module.ceylon", "modules/bug1100/test.ceylon");
    assertEquals("Compilation failed", Boolean.TRUE, ceylonTask.call());
}
Also used : CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) Test(org.junit.Test)

Aggregations

CeyloncTaskImpl (org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl)62 Test (org.junit.Test)51 File (java.io.File)34 JarFile (java.util.jar.JarFile)26 LinkedList (java.util.LinkedList)23 ErrorCollector (org.eclipse.ceylon.compiler.java.test.ErrorCollector)23 ZipEntry (java.util.zip.ZipEntry)13 ZipFile (java.util.zip.ZipFile)13 CompilerError (org.eclipse.ceylon.compiler.java.test.CompilerError)12 ExitState (org.eclipse.ceylon.compiler.java.launcher.Main.ExitState)7 CeyloncTool (org.eclipse.ceylon.compiler.java.tools.CeyloncTool)6 ArrayList (java.util.ArrayList)5 CeyloncFileManager (org.eclipse.ceylon.compiler.java.tools.CeyloncFileManager)5 TaskEvent (org.eclipse.ceylon.langtools.source.util.TaskEvent)4 TaskListener (org.eclipse.ceylon.langtools.source.util.TaskListener)4 Set (java.util.Set)3 DiagnosticListener (org.eclipse.ceylon.javax.tools.DiagnosticListener)3 JCCompilationUnit (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCCompilationUnit)3 Module (org.eclipse.ceylon.model.typechecker.model.Module)3 Ignore (org.junit.Ignore)3