Search in sources :

Example 41 with CeyloncTaskImpl

use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.

the class CMRTests method testMdlByName.

//
// Modules
@Test
public void testMdlByName() throws IOException {
    List<String> options = new LinkedList<String>();
    options.add("-src");
    options.add(getPackagePath() + "/modules/byName");
    options.addAll(defaultOptions);
    CeyloncTaskImpl task = getCompilerTask(options, null, Arrays.asList("default", "mod"));
    Boolean ret = task.call();
    assertTrue(ret);
    File carFile = getModuleArchive("default", null);
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    ZipEntry moduleClass = car.getEntry("def/Foo.class");
    assertNotNull(moduleClass);
    ZipEntry moduleClassDir = car.getEntry("def/");
    assertNotNull(moduleClassDir);
    assertTrue(moduleClassDir.isDirectory());
    car.close();
    carFile = getModuleArchive("mod", "1");
    assertTrue(carFile.exists());
    car = new JarFile(carFile);
    moduleClass = car.getEntry("mod/$module_.class");
    assertNotNull(moduleClass);
    moduleClassDir = car.getEntry("mod/");
    assertNotNull(moduleClassDir);
    assertTrue(moduleClassDir.isDirectory());
    car.close();
}
Also used : ZipEntry(java.util.zip.ZipEntry) CeyloncTaskImpl(com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl) JarFile(java.util.jar.JarFile) JarFile(java.util.jar.JarFile) ZipFile(java.util.zip.ZipFile) File(java.io.File) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 42 with CeyloncTaskImpl

use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.

the class CMRTests method testMdlAetherDependencyDefault.

@Test
public void testMdlAetherDependencyDefault() throws IOException {
    // Try to compile the ceylon module
    CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir, "-rep", "aether", "-verbose:cmr"), (DiagnosticListener<? super FileObject>) null, "modules/aetherdefault/module.ceylon", "modules/aetherdefault/foo.ceylon");
    assertEquals(Boolean.TRUE, ceylonTask.call());
    // We're assuming a standard Maven configuration here!
    File camelJar = new File(System.getProperty("user.home"), ".m2/repository/org/apache/camel/camel-core/2.9.2/camel-core-2.9.2.jar");
    assertTrue(camelJar.exists());
}
Also used : CeyloncTaskImpl(com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl) JarFile(java.util.jar.JarFile) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test)

Example 43 with CeyloncTaskImpl

use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.

the class CMRTests method testOverridesCeylonModuleShareImport.

@Test
public void testOverridesCeylonModuleShareImport() {
    setupBinaryModulesForOverridesCeylonModuleTests();
    ErrorCollector collector = new ErrorCollector();
    CeyloncTaskImpl compilerTask = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules", "-overrides", getPackagePath() + "modules/overridesCeylonModule/overrides-share-c-import.xml"), collector, "modules/overridesCeylonModule/module.ceylon");
    ModulesRetriever modulesRetriever = new ModulesRetriever(compilerTask.getContext());
    compilerTask.setTaskListener(modulesRetriever);
    Boolean result = compilerTask.call();
    Assert.assertEquals(Boolean.TRUE, result);
    Module a = modulesRetriever.modules.get("a");
    assert (a != null);
    ModuleImport cImport = getModuleImport(a, "c");
    assert (cImport != null);
    assertEquals("The 'c' module import should be seen as 'exported' after applying the overrides file", true, cImport.isExport());
}
Also used : ModuleImport(com.redhat.ceylon.model.typechecker.model.ModuleImport) ErrorCollector(com.redhat.ceylon.compiler.java.test.ErrorCollector) CeyloncTaskImpl(com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl) Module(com.redhat.ceylon.model.typechecker.model.Module) Test(org.junit.Test)

Example 44 with CeyloncTaskImpl

use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.

the class CMRTests method testMdlDependenciesFromMavenWithOverrides.

@Test
public void testMdlDependenciesFromMavenWithOverrides() throws Throwable {
    Assume.assumeTrue("Runs on JDK8", JDKUtils.jdk == JDKUtils.JDK.JDK8);
    CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir), "modules/sparkframework/module.ceylon", "modules/sparkframework/test.ceylon");
    assertEquals("Compilation failed", Boolean.TRUE, ceylonTask.call());
    runInJBossModules("run", "com.redhat.ceylon.compiler.java.test.cmr.modules.sparkframework/1", Arrays.asList("--overrides", getPackagePath() + "/modules/sparkframework/overrides-fix.xml"));
}
Also used : CeyloncTaskImpl(com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl) Test(org.junit.Test)

Example 45 with CeyloncTaskImpl

use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.

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 shared: 'b.hidden'"));
}
Also used : ErrorCollector(com.redhat.ceylon.compiler.java.test.ErrorCollector) CompilerError(com.redhat.ceylon.compiler.java.test.CompilerError) CeyloncTaskImpl(com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl) Test(org.junit.Test)

Aggregations

CeyloncTaskImpl (com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl)53 Test (org.junit.Test)43 File (java.io.File)27 JarFile (java.util.jar.JarFile)19 ErrorCollector (com.redhat.ceylon.compiler.java.test.ErrorCollector)18 LinkedList (java.util.LinkedList)18 ZipEntry (java.util.zip.ZipEntry)13 CompilerError (com.redhat.ceylon.compiler.java.test.CompilerError)11 ZipFile (java.util.zip.ZipFile)8 ExitState (com.redhat.ceylon.compiler.java.launcher.Main.ExitState)6 CeyloncFileManager (com.redhat.ceylon.compiler.java.tools.CeyloncFileManager)5 CeyloncTool (com.redhat.ceylon.compiler.java.tools.CeyloncTool)5 ArrayList (java.util.ArrayList)5 TaskEvent (com.sun.source.util.TaskEvent)4 TaskListener (com.sun.source.util.TaskListener)4 Module (com.redhat.ceylon.model.typechecker.model.Module)3 JCCompilationUnit (com.sun.tools.javac.tree.JCTree.JCCompilationUnit)3 DiagnosticListener (javax.tools.DiagnosticListener)3 Ignore (org.junit.Ignore)3 JavaPositionsRetriever (com.redhat.ceylon.compiler.java.codegen.JavaPositionsRetriever)2