use of com.redhat.ceylon.common.tool.OptionArgumentException in project ceylon-compiler by ceylon.
the class HelpToolTests method testHelpCompiler.
@Test
public void testHelpCompiler() {
ToolModel<CeylonHelpTool> model = pluginLoader.loadToolModel("help");
Assert.assertNotNull(model);
CeylonHelpTool tool = pluginFactory.bindArguments(model, getMainTool(), Arrays.asList("compile"));
tool.setToolLoader(pluginLoader);
tool.run();
try {
pluginFactory.bindArguments(model, getMainTool(), Arrays.asList("--", "compile", "--javac="));
Assert.fail();
} catch (OptionArgumentException e) {
Assert.assertEquals("Unexpected argument '--javac=' to command 'help'", e.getMessage());
}
}
use of com.redhat.ceylon.common.tool.OptionArgumentException in project ceylon-compiler by ceylon.
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
}
}
use of com.redhat.ceylon.common.tool.OptionArgumentException in project ceylon-compiler by ceylon.
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(), options("--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(), options("--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(), options("--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(), options("--javac=-Xlint:cast", "--src=test/src", "com.redhat.ceylon.tools.test.ceylon"));
}
try {
CeylonCompileTool tool = pluginFactory.bindArguments(model, getMainTool(), options("--javac=-Xlint:monkey", "--src=test/src", "com.redhat.ceylon.tools.test.ceylon"));
Assert.fail("Tool should have thrown an exception");
} catch (OptionArgumentException x) {
Assert.assertEquals("Unknown --javac option: -Xlint:monkey", x.getMessage());
}
}
use of com.redhat.ceylon.common.tool.OptionArgumentException in project ceylon-compiler by ceylon.
the class CompilerToolTests method testCompileModuleAndVersion.
@Test
public void testCompileModuleAndVersion() 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.ceylon/1.0"));
Assert.fail();
} catch (OptionArgumentException e) {
Assert.assertEquals("Invalid module name or source file: com.redhat.ceylon.tools.test.ceylon/1.0\n" + "Module names should not contain any version part.\n" + "Source file names should be given relative to the current directory.", e.getMessage());
}
}
use of com.redhat.ceylon.common.tool.OptionArgumentException 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
}
}
Aggregations