Search in sources :

Example 1 with CeylonCompileTool

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

the class NewProjectToolTests method testHelloWorldNoAntNoEclipseCompiles.

@Test
public void testHelloWorldNoAntNoEclipseCompiles() throws Exception {
    ToolModel<CeylonNewTool> newModel = pluginLoader.loadToolModel("new");
    Assert.assertNotNull(newModel);
    Assert.assertTrue(newModel.isPorcelain());
    Path tmpPath = Files.createTempDirectory("ceylon-new-");
    File tmpDir = tmpPath.toFile();
    try {
        CeylonNewTool newTool = pluginFactory.bindArguments(newModel, getMainTool(), args("--from=../dist/templates", "hello-world", "--module-name=org.example.hello", "--module-version=1", "--ant=false", "--eclipse=false", tmpDir.getAbsolutePath()));
        runTool(newTool);
        ToolModel<CeylonCompileTool> compileModel = pluginLoader.loadToolModel("compile");
        Assert.assertNotNull(compileModel);
        CeylonCompileTool compileTool = pluginFactory.bindArguments(compileModel, getMainTool(), toolOptions("--src=" + tmpDir.getAbsolutePath() + "/source", "--out=" + tmpDir.getAbsolutePath(), "org.example.hello"));
        runTool(compileTool);
    } finally {
        delete(tmpDir);
    }
}
Also used : Path(java.nio.file.Path) CeylonCompileTool(org.eclipse.ceylon.compiler.CeylonCompileTool) CeylonNewTool(org.eclipse.ceylon.tools.new_.CeylonNewTool) File(java.io.File) Test(org.junit.Test)

Example 2 with CeylonCompileTool

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

the class CompilerToolTests method testBug1183.

@Test
public void testBug1183() 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.bug1183"));
    try {
        tool.run();
        Assert.fail("Tool should have thrown an exception");
    } catch (CompilerErrorException e) {
    // We expect this, not a FatalToolError
    }
}
Also used : CeylonCompileTool(org.eclipse.ceylon.compiler.CeylonCompileTool) CompilerErrorException(org.eclipse.ceylon.compiler.CompilerErrorException) Test(org.junit.Test)

Example 3 with CeylonCompileTool

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

the class CompilerToolTests method testCompileWithErroneous.

@Test
public void testCompileWithErroneous() 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.erroneous"));
    try {
        tool.run();
        Assert.fail("Tool should have thrown an exception");
    } catch (CompilerErrorException x) {
        Assert.assertEquals("There was 1 error", x.getMessage());
    } catch (Throwable t) {
        t.printStackTrace();
        Assert.fail("Unexpected exception");
    }
}
Also used : CeylonCompileTool(org.eclipse.ceylon.compiler.CeylonCompileTool) CompilerErrorException(org.eclipse.ceylon.compiler.CompilerErrorException) Test(org.junit.Test)

Example 4 with CeylonCompileTool

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

the class CompilerToolTests method testValidatingJavaOptions.

@Test
public void testValidatingJavaOptions() throws Exception {
    ToolModel<CeylonCompileTool> model = pluginLoader.loadToolModel("compile");
    Assert.assertNotNull(model);
    try {
        CeylonCompileTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--javac=-target=foo", "com.example"));
        Assert.fail("Tool should have thrown an exception");
    } catch (OptionArgumentException x) {
        Assert.assertEquals("Invalid --javac option: -target: invalid target release: foo", x.getMessage());
    }
    try {
        CeylonCompileTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--javac=-source=foo", "com.example"));
        Assert.fail("Tool should have thrown an exception");
    } catch (OptionArgumentException x) {
        Assert.assertEquals("Invalid --javac option: -source: invalid source release: foo", x.getMessage());
    }
    try {
        CeylonCompileTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--javac=-monkey", "com.example"));
        Assert.fail("Tool should have thrown an exception");
    } catch (OptionArgumentException x) {
        Assert.assertEquals("Unknown --javac option: -monkey", x.getMessage());
    }
    {
        CeylonCompileTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--javac=-Xlint:cast", "--src=test/src", "org.eclipse.ceylon.tools.test.ceylon"));
    }
    try {
        CeylonCompileTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--javac=-Xlint:monkey", "--src=test/src", "org.eclipse.ceylon.tools.test.ceylon"));
        Assert.fail("Tool should have thrown an exception");
    } catch (OptionArgumentException x) {
        Assert.assertEquals("Unknown --javac option: -Xlint:monkey", x.getMessage());
    }
}
Also used : CeylonCompileTool(org.eclipse.ceylon.compiler.CeylonCompileTool) OptionArgumentException(org.eclipse.ceylon.common.tool.OptionArgumentException) Test(org.junit.Test)

Example 5 with CeylonCompileTool

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

the class CompilerToolTests method testCompileValidEncoding.

@Test
public void testCompileValidEncoding() throws Exception {
    ToolModel<CeylonCompileTool> model = pluginLoader.loadToolModel("compile");
    Assert.assertNotNull(model);
    CeylonCompileTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--src=test/src", "--encoding=UTF-8", "org.eclipse.ceylon.tools.test.ceylon"));
}
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