Search in sources :

Example 11 with CeylonCompileTool

use of org.eclipse.ceylon.compiler.CeylonCompileTool in project ceylon by eclipse.

the class CompilerToolTests method testCompileCwd.

@Test
public void testCompileCwd() throws Exception {
    File destDir = destFile("compilecwdtest");
    FileUtil.delete(destDir);
    destDir.mkdirs();
    FileUtil.copyAll(new File("test/src/org/eclipse/ceylon/tools/test/cwdtest"), destDir);
    ToolModel<CeylonCompileTool> model = pluginLoader.loadToolModel("compile");
    Assert.assertNotNull(model);
    CeylonCompileTool tool = pluginFactory.bindArguments(model, getMainTool(), Arrays.asList("--cwd", destDir.getPath(), "--sysrep", getSysRepPath(), "--src=src", "--resource=res", "--out=mod", "--rep", "aether", "--overrides", "overrides.xml", // Unfortunately --cwd doesn't affect Java options
    "--javac=-cp=" + getClassPathAsPath(), "cwdtest"));
    tool.run();
    File carFile = getModuleArchive("cwdtest", "1", (new File(destDir, "mod")).getPath());
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    ZipEntry entry = car.getEntry("cwdtest/test.txt");
    assertNotNull(entry);
    car.close();
}
Also used : CeylonCompileTool(org.eclipse.ceylon.compiler.CeylonCompileTool) ZipEntry(java.util.zip.ZipEntry) JarFile(java.util.jar.JarFile) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 12 with CeylonCompileTool

use of org.eclipse.ceylon.compiler.CeylonCompileTool in project ceylon by eclipse.

the class CompilerToolTests method testTargetInvalid.

@Test
public void testTargetInvalid() throws Exception {
    ToolModel<CeylonCompileTool> model = pluginLoader.loadToolModel("compile");
    Assert.assertNotNull(model);
    try {
        CeylonCompileTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--src=test/src", "--target=56", "org.eclipse.ceylon.tools.test.java8"));
    } catch (InvalidOptionValueException e) {
        Assert.assertEquals("Invalid value '56' given for option 'target' to command 'compile'", e.getMessage());
    }
}
Also used : CeylonCompileTool(org.eclipse.ceylon.compiler.CeylonCompileTool) InvalidOptionValueException(org.eclipse.ceylon.common.tool.OptionArgumentException.InvalidOptionValueException) Test(org.junit.Test)

Example 13 with CeylonCompileTool

use of org.eclipse.ceylon.compiler.CeylonCompileTool in project ceylon by eclipse.

the class CompilerToolTests method testCompileNoSuchModule.

@Test
public void testCompileNoSuchModule() throws Exception {
    ToolModel<CeylonCompileTool> model = pluginLoader.loadToolModel("compile");
    Assert.assertNotNull(model);
    try {
        CeylonCompileTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--src=test/src", "org.eclipse.ceylon.tools.test.nosuchmodule"));
        Assert.fail();
    } catch (OptionArgumentException e) {
        Assert.assertEquals("Module org.eclipse.ceylon.tools.test.nosuchmodule not found in source directories: test" + File.separator + "src", e.getMessage());
    }
}
Also used : CeylonCompileTool(org.eclipse.ceylon.compiler.CeylonCompileTool) OptionArgumentException(org.eclipse.ceylon.common.tool.OptionArgumentException) Test(org.junit.Test)

Example 14 with CeylonCompileTool

use of org.eclipse.ceylon.compiler.CeylonCompileTool in project ceylon by eclipse.

the class CompilerToolTests method testUnknownWarning.

@Test
public void testUnknownWarning() throws Exception {
    ToolModel<CeylonCompileTool> model = pluginLoader.loadToolModel("compile");
    Assert.assertNotNull(model);
    try {
        CeylonCompileTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--suppress-warning=blah"));
        Assert.fail("Tool should have thrown an exception");
    } catch (OptionArgumentException e) {
        Assert.assertEquals("Invalid value 'blah' given for option 'suppress-warning' to command 'compile'", e.getMessage());
    // We expect this, not a FatalToolError
    }
}
Also used : CeylonCompileTool(org.eclipse.ceylon.compiler.CeylonCompileTool) OptionArgumentException(org.eclipse.ceylon.common.tool.OptionArgumentException) Test(org.junit.Test)

Example 15 with CeylonCompileTool

use of org.eclipse.ceylon.compiler.CeylonCompileTool in project ceylon by eclipse.

the class CompilerToolTests method testCompile.

@Test
public void testCompile() throws Exception {
    ToolModel<CeylonCompileTool> model = pluginLoader.loadToolModel("compile");
    Assert.assertNotNull(model);
    CeylonCompileTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--src=test/src", "org.eclipse.ceylon.tools.test.ceylon"));
    tool.run();
}
Also used : CeylonCompileTool(org.eclipse.ceylon.compiler.CeylonCompileTool) Test(org.junit.Test)

Aggregations

CeylonCompileTool (org.eclipse.ceylon.compiler.CeylonCompileTool)29 Test (org.junit.Test)29 OptionArgumentException (org.eclipse.ceylon.common.tool.OptionArgumentException)8 CompilerErrorException (org.eclipse.ceylon.compiler.CompilerErrorException)6 File (java.io.File)4 JarFile (java.util.jar.JarFile)3 SystemErrorException (org.eclipse.ceylon.compiler.SystemErrorException)2 Path (java.nio.file.Path)1 ZipEntry (java.util.zip.ZipEntry)1 NonFatalToolMessage (org.eclipse.ceylon.common.tool.NonFatalToolMessage)1 InvalidOptionValueException (org.eclipse.ceylon.common.tool.OptionArgumentException.InvalidOptionValueException)1 ToolUsageError (org.eclipse.ceylon.common.tool.ToolUsageError)1 CeylonNewTool (org.eclipse.ceylon.tools.new_.CeylonNewTool)1