use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.
the class CMRTests method testMdlAetherMissingDependenciesOverride.
@Test
public void testMdlAetherMissingDependenciesOverride() throws IOException {
// Try to compile the ceylon module
CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir, "-rep", "aether", "-overrides", getPackagePath() + "/modules/bug1100/overrides.xml"), "modules/bug1100/module.ceylon", "modules/bug1100/test.ceylon");
assertEquals("Compilation failed", Boolean.TRUE, ceylonTask.call());
}
use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.
the class CompilerTests method assertErrors.
protected void assertErrors(String[] ceylonFiles, List<String> options, Throwable expectedException, boolean includeWarnings, CompilerError... expectedErrors) {
// make a compiler task
// FIXME: runFileManager.setSourcePath(dir);
ErrorCollector collector = new ErrorCollector();
CeyloncTaskImpl task = getCompilerTask(options, collector, ceylonFiles);
boolean expectedToFail = false;
Diagnostic.Kind lowestErrorLevel = includeWarnings ? Diagnostic.Kind.WARNING : Diagnostic.Kind.ERROR;
for (CompilerError expectedError : expectedErrors) {
if (expectedError.kind == Diagnostic.Kind.ERROR) {
expectedToFail = true;
}
// we are interested in WARNING + ERROR kinds
if (lowestErrorLevel.compareTo(expectedError.kind) == -1)
lowestErrorLevel = expectedError.kind;
}
EnumSet<Diagnostic.Kind> kinds = EnumSet.range(Diagnostic.Kind.ERROR, lowestErrorLevel);
// now compile it all the way
Throwable ex = null;
ExitState exitState = task.call2();
switch(exitState.ceylonState) {
case OK:
if (expectedToFail) {
Assert.fail("Compilation successful (it should have failed!)");
}
break;
case BUG:
if (expectedException == null) {
throw new AssertionError("Compiler bug", exitState.abortingException);
}
ex = exitState.abortingException;
break;
case ERROR:
if (!expectedToFail) {
Assert.fail("Compilation successful (it should have failed!)");
}
break;
case SYS:
Assert.fail("System error");
break;
default:
Assert.fail("Unknown exit state");
}
if (ex != null) {
if (expectedException == null) {
throw new AssertionError("Compilation terminated with unexpected error", ex);
} else if (expectedException.getClass() != ex.getClass() || !eq(expectedException.getMessage(), ex.getMessage())) {
throw new AssertionError("Compilation terminated with a different error than the expected " + expectedException, ex);
}
} else if (expectedException != null) {
Assert.fail("Expected compiler exception " + expectedException);
}
Set<CompilerError> actualErrors = collector.get(kinds);
compareErrors(actualErrors, expectedErrors);
}
use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.
the class CarGenerationTests method testCarResourceAlternativeRoot.
@Test
public void testCarResourceAlternativeRoot() throws IOException {
List<String> options = new LinkedList<String>();
options.add("-src");
options.add(getPackagePath() + "resmodules/altrootdir/source");
options.add("-res");
options.add(getPackagePath() + "resmodules/altrootdir/resource");
options.add("-resroot");
options.add("ALTROOT");
options.addAll(defaultOptions);
CeyloncTaskImpl task = getCompilerTask(options, null, Arrays.asList("test.altrootdir"));
Boolean ret = task.call();
assertTrue(ret);
File carFile = getModuleArchive("test.altrootdir", "1.0");
assertTrue(carFile.exists());
JarFile car = new JarFile(carFile);
ZipEntry carEntry = car.getEntry("test/altrootdir/README.txt");
assertNotNull(carEntry);
carEntry = car.getEntry("rootfile");
assertNotNull(carEntry);
carEntry = car.getEntry("test/altrootdir/$module_.class");
assertNotNull(carEntry);
car.close();
}
use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.
the class CMRTests method testOverridesCeylonModuleInSourceImport.
@Test
public void testOverridesCeylonModuleInSourceImport() {
setupBinaryModulesForOverridesCeylonModuleTests();
ErrorCollector collector = new ErrorCollector();
CeyloncTaskImpl compilerTask = getCompilerTask(Arrays.asList("-continue", "-src", getPackagePath() + "/modules", "-overrides", getPackagePath() + "modules/overridesCeylonModule/overrides-a-version.xml"), collector, "modules/overridesCeylonModule/module.ceylon");
ModulesRetriever modulesRetriever = new ModulesRetriever(compilerTask.getContext());
compilerTask.setTaskListener(modulesRetriever);
Boolean result = compilerTask.call();
Assert.assertEquals(Boolean.FALSE, result);
compareErrors(collector.get(Diagnostic.Kind.ERROR), new CompilerError(2, "The module import should not be overriden, since it is explicitely imported by a project source module"));
assert (modulesRetriever.modules != null);
Module a = modulesRetriever.modules.get("a");
Module b = modulesRetriever.modules.get("b");
Module c = modulesRetriever.modules.get("c");
assert (a != null);
assert (b != null);
assert (c != null);
assertEquals("The version override should not be applied to modules imported in source code", "2", a.getVersion());
assertEquals("The version override should not be applied to modules imported in source code", "2", b.getVersion());
assertEquals("The version override should not be applied to modules imported in source code", "2", c.getVersion());
}
use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.
the class CMRTests method testMdlModuleDefaultIncrementalNoPackage.
@Test
public void testMdlModuleDefaultIncrementalNoPackage() throws IOException {
List<String> options = new LinkedList<String>();
options.add("-src");
options.add(getPackagePath() + "/modules/def");
options.addAll(defaultOptions);
CeyloncTaskImpl task = getCompilerTask(options, null, Collections.<String>emptyList(), "modules/def/A.ceylon");
Boolean ret = task.call();
assertTrue(ret);
task = getCompilerTask(options, null, Collections.<String>emptyList(), "modules/def/RequiresA.ceylon");
ret = task.call();
assertTrue(ret);
}
Aggregations