Search in sources :

Example 6 with OptionArgumentException

use of org.eclipse.ceylon.common.tool.OptionArgumentException in project ceylon by eclipse.

the class ClasspathToolTests method testNoArgs.

@Test
public void testNoArgs() throws Exception {
    ToolModel<CeylonClasspathTool> model = pluginLoader.loadToolModel("classpath");
    Assert.assertNotNull(model);
    try {
        CeylonClasspathTool tool = pluginFactory.bindArguments(model, getMainTool(), Collections.<String>emptyList());
        Assert.fail();
    } catch (OptionArgumentException e) {
    // asserting this is thrown
    }
}
Also used : OptionArgumentException(org.eclipse.ceylon.common.tool.OptionArgumentException) CeylonClasspathTool(org.eclipse.ceylon.tools.classpath.CeylonClasspathTool) Test(org.junit.Test)

Example 7 with OptionArgumentException

use of org.eclipse.ceylon.common.tool.OptionArgumentException 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 8 with OptionArgumentException

use of org.eclipse.ceylon.common.tool.OptionArgumentException in project ceylon by eclipse.

the class CompilerToolTests method testBug1179.

@Test
public void testBug1179() throws Exception {
    ToolModel<CeylonCompileTool> model = pluginLoader.loadToolModel("compile");
    Assert.assertNotNull(model);
    try {
        CeylonCompileTool tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--src=test/src", "3"));
        Assert.fail("Tool should have thrown an exception");
    } catch (OptionArgumentException x) {
        Assert.assertEquals("Invalid module name or source file: 3\n" + "Module names should not contain any version part.\n" + "Source file names should be given relative to the current directory.", x.getMessage());
    }
}
Also used : CeylonCompileTool(org.eclipse.ceylon.compiler.CeylonCompileTool) OptionArgumentException(org.eclipse.ceylon.common.tool.OptionArgumentException) Test(org.junit.Test)

Example 9 with OptionArgumentException

use of org.eclipse.ceylon.common.tool.OptionArgumentException 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 10 with OptionArgumentException

use of org.eclipse.ceylon.common.tool.OptionArgumentException 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)

Aggregations

OptionArgumentException (org.eclipse.ceylon.common.tool.OptionArgumentException)19 Test (org.junit.Test)18 CeylonCompileTool (org.eclipse.ceylon.compiler.CeylonCompileTool)8 CeylonImportJarTool (org.eclipse.ceylon.tools.importjar.CeylonImportJarTool)3 CeylonRunTool (ceylon.modules.bootstrap.CeylonRunTool)1 AbstractToolTest (org.eclipse.ceylon.common.tool.AbstractToolTest)1 FatalToolError (org.eclipse.ceylon.common.tool.FatalToolError)1 ModelException (org.eclipse.ceylon.common.tool.ModelException)1 NoSuchToolException (org.eclipse.ceylon.common.tool.NoSuchToolException)1 ToolError (org.eclipse.ceylon.common.tool.ToolError)1 TestSubtoolTool (org.eclipse.ceylon.common.tool.example.TestSubtoolTool)1 CeylonHelpTool (org.eclipse.ceylon.common.tools.help.CeylonHelpTool)1 CeylonClasspathTool (org.eclipse.ceylon.tools.classpath.CeylonClasspathTool)1 CeylonInfoTool (org.eclipse.ceylon.tools.info.CeylonInfoTool)1 CeylonMavenExportTool (org.eclipse.ceylon.tools.maven.export.CeylonMavenExportTool)1 CeylonSrcTool (org.eclipse.ceylon.tools.src.CeylonSrcTool)1