Search in sources :

Example 16 with CeylonCompileTool

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

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(), options("--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(com.redhat.ceylon.compiler.CeylonCompileTool) OptionArgumentException(com.redhat.ceylon.common.tool.OptionArgumentException) Test(org.junit.Test)

Example 17 with CeylonCompileTool

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

the class CompilerToolTests method testBadIntegerLiteral.

@Test
public void testBadIntegerLiteral() 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.badintegerliteral"));
    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 18 with CeylonCompileTool

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

the class CompilerToolTests method testCompileNoSuchModuleDotCeylon.

@Test
public void testCompileNoSuchModuleDotCeylon() 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.ceylon"));
        Assert.fail();
    } catch (OptionArgumentException e) {
        Assert.assertEquals("file not found: com.redhat.ceylon.tools.test.nosuchmodule.ceylon", e.getMessage());
    }
}
Also used : CeylonCompileTool(com.redhat.ceylon.compiler.CeylonCompileTool) OptionArgumentException(com.redhat.ceylon.common.tool.OptionArgumentException) Test(org.junit.Test)

Example 19 with CeylonCompileTool

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

the class CompilerToolTests method testDefaultModuleNoFiles.

@Test
public void testDefaultModuleNoFiles() 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/empty", "default"));
        tool.run();
        Assert.fail("Tool should have thrown an exception");
    } catch (ToolUsageError e) {
        Assert.assertEquals("Module default does not contain any sources or resources", e.getMessage());
    }
}
Also used : CeylonCompileTool(com.redhat.ceylon.compiler.CeylonCompileTool) ToolUsageError(com.redhat.ceylon.common.tool.ToolUsageError) Test(org.junit.Test)

Example 20 with CeylonCompileTool

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

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/com/redhat/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(), "--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(com.redhat.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)

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