use of com.redhat.ceylon.compiler.java.test.ErrorCollector in project ceylon-compiler by ceylon.
the class CMRTests method testMdlAetherMissingDependencies.
@Test
public void testMdlAetherMissingDependencies() throws IOException {
CompilerError[] expectedErrors = new CompilerError[] { new CompilerError(6, "Error while loading the org.apache.camel:camel-jetty/2.9.4 module:\n" + " Declaration 'org.apache.camel.component.http.HttpComponent' could not be found in module 'org.apache.camel:camel-jetty' or its imported modules"), new CompilerError(10, "argument must be assignable to parameter 'arg1' of 'addComponent' in 'DefaultCamelContext': 'JettyHttpComponent' is not assignable to 'Component?': Error while loading the org.apache.camel:camel-jetty/2.9.4 module:\n" + " Declaration 'org.apache.camel.component.http.HttpComponent' could not be found in module 'org.apache.camel:camel-jetty' or its imported modules") };
ErrorCollector collector = new ErrorCollector();
// Try to compile the ceylon module
CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir, "-rep", "aether"), collector, "modules/bug1100/module.ceylon", "modules/bug1100/test.ceylon");
assertEquals("Compilation failed", Boolean.FALSE, ceylonTask.call());
TreeSet<CompilerError> actualErrors = collector.get(Diagnostic.Kind.ERROR);
compareErrors(actualErrors, expectedErrors);
}
use of com.redhat.ceylon.compiler.java.test.ErrorCollector in project ceylon-compiler by ceylon.
the class RecoveryTests method testSyntaxErrorInModule.
@Test
public void testSyntaxErrorInModule() throws IOException {
String subPath = "modules/syntaxErrorInModule";
String srcPath = getPackagePath() + subPath;
List<String> options = new LinkedList<String>();
options.add("-src");
options.add(srcPath);
options.addAll(defaultOptions);
options.add("-continue");
ErrorCollector c = new ErrorCollector();
CeyloncTaskImpl task = getCompilerTask(options, c, Arrays.asList("okmodule"), subPath + "/someok.ceylon");
Boolean ret = task.call();
assertFalse(ret);
TreeSet<CompilerError> actualErrors = c.get(Diagnostic.Kind.ERROR);
compareErrors(actualErrors, new CompilerError(-1, "incorrect syntax: no viable alternative at token end of file"), new CompilerError(20, "incorrect syntax: mismatched token 'ERROR' expecting initial-lowercase identifier"), new CompilerError(20, "incorrect syntax: no viable alternative at token '\"1.0.0\"'"), new CompilerError(20, "incorrect syntax: no viable alternative at token 'okmodule'"));
File carFile = getModuleArchive("default", null);
assertTrue(carFile.exists());
JarFile car = new JarFile(carFile);
ZipEntry moduleClass = car.getEntry("foobar_.class");
assertNotNull(moduleClass);
car.close();
carFile = getModuleArchive("okmodule", "1.0.0");
assertFalse(carFile.exists());
}
use of com.redhat.ceylon.compiler.java.test.ErrorCollector in project ceylon-compiler by ceylon.
the class RecoveryTests method testErrorSameCompilationUnit.
@Test
public void testErrorSameCompilationUnit() throws IOException {
String subPath = "modules/errorInSameCompilationUnit";
String srcPath = getPackagePath() + subPath;
List<String> options = new LinkedList<String>();
options.add("-src");
options.add(srcPath);
options.addAll(defaultOptions);
options.add("-continue");
ErrorCollector c = new ErrorCollector();
CeyloncTaskImpl task = getCompilerTask(options, c, subPath + "/someok.ceylon");
Boolean ret = task.call();
assertFalse(ret);
TreeSet<CompilerError> actualErrors = c.get(Diagnostic.Kind.ERROR);
compareErrors(actualErrors, new CompilerError(23, "type does not exist: 'ERROR'"));
File carFile = getModuleArchive("default", null);
assertTrue(carFile.exists());
JarFile car = new JarFile(carFile);
ZipEntry moduleClass = car.getEntry("a_.class");
assertNotNull(moduleClass);
car.close();
}
use of com.redhat.ceylon.compiler.java.test.ErrorCollector in project ceylon-compiler by ceylon.
the class RecoveryTests method testMissingImport.
@Test
public void testMissingImport() throws IOException {
String subPath = "modules/missingImport";
String srcPath = getPackagePath() + subPath;
List<String> options = new LinkedList<String>();
options.add("-src");
options.add(srcPath);
options.addAll(defaultOptions);
options.add("-continue");
ErrorCollector c = new ErrorCollector();
CeyloncTaskImpl task = getCompilerTask(options, c, Arrays.asList("okmodule"), subPath + "/someok.ceylon");
Boolean ret = task.call();
assertFalse(ret);
TreeSet<CompilerError> actualErrors = c.get(Diagnostic.Kind.ERROR);
compareErrors(actualErrors, new CompilerError(21, "cannot find module artifact notfound-1(.car|.jar)\n \t- dependency tree: okmodule/1.0.0 -> notfound/1"));
File carFile = getModuleArchive("default", null);
assertTrue(carFile.exists());
JarFile car = new JarFile(carFile);
ZipEntry moduleClass = car.getEntry("foobar_.class");
assertNotNull(moduleClass);
car.close();
carFile = getModuleArchive("okmodule", "1.0.0");
assertFalse(carFile.exists());
}
use of com.redhat.ceylon.compiler.java.test.ErrorCollector in project ceylon-compiler by ceylon.
the class RecoveryTests method compileIgnoringCeylonErrors.
private ErrorCollector compileIgnoringCeylonErrors(String... ceylon) {
ErrorCollector c = new ErrorCollector();
getCompilerTask(defaultOptions, c, ceylon).call2();
Assert.assertTrue("Expected only ceylon errors: " + c.getAssertionFailureMessage(), 0 == c.getNumBackendErrors());
return c;
}
Aggregations