Search in sources :

Example 1 with CeylonCompileTool

use of com.redhat.ceylon.compiler.CeylonCompileTool in project ceylon-compiler by ceylon.

the class CompilerToolTests method testCompileMultipleAutodetect.

@Test
public void testCompileMultipleAutodetect() throws Exception {
    File carFile1 = getModuleArchive("com.first", "1");
    carFile1.delete();
    File carFile2 = getModuleArchive("com.second", "1");
    carFile2.delete();
    File carFile3 = getModuleArchive("single", "1");
    carFile3.delete();
    ToolModel<CeylonCompileTool> model = pluginLoader.loadToolModel("compile");
    Assert.assertNotNull(model);
    CeylonCompileTool tool = pluginFactory.bindArguments(model, getMainTool(), options("--src=test/src/com/redhat/ceylon/tools/test/bugCC59"));
    tool.run();
    assertTrue(carFile1.exists() && carFile2.exists() && carFile3.exists());
}
Also used : CeylonCompileTool(com.redhat.ceylon.compiler.CeylonCompileTool) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 2 with CeylonCompileTool

use of com.redhat.ceylon.compiler.CeylonCompileTool in project ceylon-compiler by ceylon.

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(), options("--src=test/src", "com.redhat.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(com.redhat.ceylon.compiler.CeylonCompileTool) CompilerErrorException(com.redhat.ceylon.compiler.CompilerErrorException) Test(org.junit.Test)

Example 3 with CeylonCompileTool

use of com.redhat.ceylon.compiler.CeylonCompileTool in project ceylon-compiler by ceylon.

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(), options("--src=test/src", "com.redhat.ceylon.tools.test.nosuchmodule"));
        Assert.fail();
    } catch (OptionArgumentException e) {
        Assert.assertEquals("Module com.redhat.ceylon.tools.test.nosuchmodule not found in source directories: test" + File.separator + "src", e.getMessage());
    }
}
Also used : CeylonCompileTool(com.redhat.ceylon.compiler.CeylonCompileTool) OptionArgumentException(com.redhat.ceylon.common.tool.OptionArgumentException) Test(org.junit.Test)

Example 4 with CeylonCompileTool

use of com.redhat.ceylon.compiler.CeylonCompileTool in project ceylon-compiler by ceylon.

the class CompilerToolTests method testCompileWithOomeException.

@Test
public void testCompileWithOomeException() throws Exception {
    ToolModel<CeylonCompileTool> model = pluginLoader.loadToolModel("compile");
    Assert.assertNotNull(model);
    CeylonCompileTool tool = pluginFactory.bindArguments(model, getMainTool(), options("--src=test/src", "com.redhat.ceylon.tools.test.oome"));
    try {
        tool.run();
        Assert.fail("Tool should have thrown an exception");
    } catch (SystemErrorException x) {
        Assert.assertEquals("java.lang.OutOfMemoryError", x.getMessage());
    }
}
Also used : CeylonCompileTool(com.redhat.ceylon.compiler.CeylonCompileTool) SystemErrorException(com.redhat.ceylon.compiler.SystemErrorException) Test(org.junit.Test)

Example 5 with CeylonCompileTool

use of com.redhat.ceylon.compiler.CeylonCompileTool in project ceylon-compiler by ceylon.

the class CompilerToolTests method testCompileWithAnalysisErrors.

@Test
public void testCompileWithAnalysisErrors() throws Exception {
    ToolModel<CeylonCompileTool> model = pluginLoader.loadToolModel("compile");
    Assert.assertNotNull(model);
    CeylonCompileTool tool = pluginFactory.bindArguments(model, getMainTool(), options("--src=test/src", "com.redhat.ceylon.tools.test.analysis"));
    try {
        tool.run();
        Assert.fail("Tool should have thrown an exception");
    } catch (CompilerErrorException x) {
        Assert.assertEquals("There were 3 errors", x.getMessage());
    } catch (Throwable t) {
        t.printStackTrace();
        Assert.fail("Unexpected exception");
    }
}
Also used : CeylonCompileTool(com.redhat.ceylon.compiler.CeylonCompileTool) CompilerErrorException(com.redhat.ceylon.compiler.CompilerErrorException) Test(org.junit.Test)

Aggregations

CeylonCompileTool (com.redhat.ceylon.compiler.CeylonCompileTool)27 Test (org.junit.Test)27 OptionArgumentException (com.redhat.ceylon.common.tool.OptionArgumentException)8 CompilerErrorException (com.redhat.ceylon.compiler.CompilerErrorException)6 File (java.io.File)4 JarFile (java.util.jar.JarFile)3 ToolUsageError (com.redhat.ceylon.common.tool.ToolUsageError)2 SystemErrorException (com.redhat.ceylon.compiler.SystemErrorException)2 Path (java.nio.file.Path)1 ZipEntry (java.util.zip.ZipEntry)1