use of org.eclipse.ceylon.compiler.java.test.ErrorCollector in project ceylon by eclipse.
the class CarGenerationTests method testCarWithServicesGreetRecompile.
/**
* Whole module recompilation
*/
@Test
public void testCarWithServicesGreetRecompile() throws IOException {
// first compile the old version
testCarWithServicesGreet();
// then recompile
ErrorCollector ec = new ErrorCollector();
List<String> options = new LinkedList<String>();
options.add("-src");
options.add(getPackagePath() + "services/greet2/source");
options.addAll(defaultOptions);
CeyloncTaskImpl task = getCompilerTask(options, ec, Arrays.asList("services"));
assertTrue(task.call());
File carFile = getModuleArchive("services", "1.0");
assertTrue(carFile.exists());
Map<String, Set<String>> services = MetaInfServices.parseAllServices(carFile);
Set<String> impls = services.get("services.Greeter");
assertNotNull(impls);
assertContains(impls, "services.HelloWorld");
assertContains(impls, "services.Gday");
assertContains(impls, "services.Bonjour");
assertEquals(3, impls.size());
assertEquals(1, services.size());
}
use of org.eclipse.ceylon.compiler.java.test.ErrorCollector in project ceylon by eclipse.
the class CMRHTTPTests method assertTimeout.
private void assertTimeout(String[] files, List<String> options) {
ErrorCollector collector = compileErrorTest(files, options, null, false, true);
Set<CompilerError> errors = collector.get(Diagnostic.Kind.ERROR);
Assert.assertTrue("Expecting a single error, got " + errors.size(), errors.size() == 1);
CompilerError err = errors.iterator().next();
Assert.assertTrue("Expecting a java.net.SocketTimeoutException, got " + err, err.toString().contains("java.net.SocketTimeoutException"));
}
use of org.eclipse.ceylon.compiler.java.test.ErrorCollector in project ceylon by eclipse.
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 org.eclipse.ceylon.compiler.java.test.ErrorCollector in project ceylon by eclipse.
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(20, "incorrect syntax: missing ':' operator at '\"1.0.0\"'"));
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 org.eclipse.ceylon.compiler.java.test.ErrorCollector in project ceylon by eclipse.
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