Search in sources :

Example 1 with CeyloncTaskImpl

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

the class CarGenerationTests method testCarResourceFilesSub.

private void testCarResourceFilesSub(boolean alternative) throws IOException {
    List<String> options = new LinkedList<String>();
    options.add("-src");
    options.add(getPackagePath() + "resmodules/files/source");
    options.add("-res");
    options.add(getPackagePath() + "resmodules/files/resource");
    options.addAll(defaultOptions);
    CeyloncTaskImpl task;
    if (alternative) {
        task = getCompilerTask(options, //                "resmodules/files/source/test/files/module.ceylon",
        "resmodules/files/resource/test/files/extrafile");
    } else {
        task = getCompilerTask(options, "resmodules/files/source/test/files/module.ceylon", "resmodules/files/resource/test/files/README.txt");
    }
    Boolean ret = task.call();
    assertTrue(ret);
    File carFile = getModuleArchive("test.files", "1.0");
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    ZipEntry moduleClass = car.getEntry("test/files/README.txt");
    assertNotNull(moduleClass);
    moduleClass = car.getEntry("test/files/extrafile");
    if (alternative) {
        assertNotNull(moduleClass);
    } else {
        assertNull(moduleClass);
    }
    moduleClass = car.getEntry("test/files/$module_.class");
    assertNotNull(moduleClass);
    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) File(java.io.File) LinkedList(java.util.LinkedList)

Example 2 with CeyloncTaskImpl

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

the class CarGenerationTests method testCarResourceSimple.

@Test
public void testCarResourceSimple() throws IOException {
    List<String> options = new LinkedList<String>();
    options.add("-src");
    options.add(getPackagePath() + "resmodules/simple/source");
    options.add("-res");
    options.add(getPackagePath() + "resmodules/simple/resource");
    options.addAll(defaultOptions);
    CeyloncTaskImpl task = getCompilerTask(options, null, Arrays.asList("test.simple"));
    Boolean ret = task.call();
    assertTrue(ret);
    File carFile = getModuleArchive("test.simple", "1.0");
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    ZipEntry moduleClass = car.getEntry("test/simple/README.txt");
    assertNotNull(moduleClass);
    moduleClass = car.getEntry("test/simple/subdir/SUBDIR.txt");
    assertNotNull(moduleClass);
    moduleClass = car.getEntry("test/simple/$module_.class");
    assertNotNull(moduleClass);
    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) File(java.io.File) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 3 with CeyloncTaskImpl

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

the class CarGenerationTests method testCarResourceRoot.

@Test
public void testCarResourceRoot() throws IOException {
    List<String> options = new LinkedList<String>();
    options.add("-src");
    options.add(getPackagePath() + "resmodules/rootdir/source");
    options.add("-res");
    options.add(getPackagePath() + "resmodules/rootdir/resource");
    options.addAll(defaultOptions);
    CeyloncTaskImpl task = getCompilerTask(options, null, Arrays.asList("test.rootdir"));
    Boolean ret = task.call();
    assertTrue(ret);
    File carFile = getModuleArchive("test.rootdir", "1.0");
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    ZipEntry carEntry = car.getEntry("test/rootdir/README.txt");
    assertNotNull(carEntry);
    carEntry = car.getEntry("rootfile");
    assertNotNull(carEntry);
    carEntry = car.getEntry("rootdir/rootsubdirfile");
    assertNotNull(carEntry);
    carEntry = car.getEntry("test/rootdir/$module_.class");
    assertNotNull(carEntry);
    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) File(java.io.File) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 4 with CeyloncTaskImpl

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

the class CarGenerationTests method testCarResourceMultipleSub.

private long testCarResourceMultipleSub(boolean reverse) throws IOException {
    List<String> options = new LinkedList<String>();
    options.add("-src");
    options.add(getPackagePath() + "resmodules/multiple/source");
    if (reverse) {
        options.add("-res");
        options.add(getPackagePath() + "resmodules/multiple/resource2");
        options.add("-res");
        options.add(getPackagePath() + "resmodules/multiple/resource");
    } else {
        options.add("-res");
        options.add(getPackagePath() + "resmodules/multiple/resource");
        options.add("-res");
        options.add(getPackagePath() + "resmodules/multiple/resource2");
    }
    options.addAll(defaultOptions);
    CeyloncTaskImpl task = getCompilerTask(options, null, Arrays.asList("test.multiple"));
    Boolean ret = task.call();
    assertTrue(ret);
    File carFile = getModuleArchive("test.multiple", "1.0");
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    ZipEntry moduleClass = car.getEntry("test/multiple/README.txt");
    long result = moduleClass.getSize();
    assertNotNull(moduleClass);
    moduleClass = car.getEntry("test/multiple/README2.txt");
    assertNotNull(moduleClass);
    moduleClass = car.getEntry("test/multiple/$module_.class");
    assertNotNull(moduleClass);
    car.close();
    return result;
}
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) File(java.io.File) LinkedList(java.util.LinkedList)

Example 5 with CeyloncTaskImpl

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

the class CarGenerationTests method testCarResourceDefault.

@Test
public void testCarResourceDefault() throws IOException {
    List<String> options = new LinkedList<String>();
    options.add("-src");
    options.add(getPackagePath() + "resmodules/default/source");
    options.add("-res");
    options.add(getPackagePath() + "resmodules/default/resource");
    options.addAll(defaultOptions);
    CeyloncTaskImpl task = getCompilerTask(options, "resmodules/default/resource/README.txt", "resmodules/default/resource/subdir/SUBDIR.txt");
    Boolean ret = task.call();
    assertTrue(ret);
    File carFile = getModuleArchive("default", null);
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    ZipEntry moduleClass = car.getEntry("README.txt");
    assertNotNull(moduleClass);
    moduleClass = car.getEntry("subdir/SUBDIR.txt");
    assertNotNull(moduleClass);
    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) File(java.io.File) LinkedList(java.util.LinkedList) 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