use of org.eclipse.ceylon.compiler.java.test.ErrorCollector in project ceylon by eclipse.
the class MiscTests method compileSDKTests.
private void compileSDKTests(String[] modules, String[] extraModules) {
String sourceDir = "../../ceylon-sdk/test-source";
String depsDir = "../../ceylon-sdk/test-deps";
// don't run this if the SDK is not checked out
File sdkFile = new File(sourceDir);
if (!sdkFile.exists())
return;
java.util.List<String> moduleNames = new ArrayList<String>(modules.length);
for (String module : modules) {
String name = "test.ceylon." + module;
// only add it if it exists
if (new File(sourceDir, name.replace('.', File.separatorChar)).isDirectory())
moduleNames.add(name);
}
for (String module : extraModules) {
moduleNames.add(module);
}
CeyloncTool compiler;
try {
compiler = new CeyloncTool();
} catch (VerifyError e) {
System.err.println("ERROR: Cannot run tests! Did you maybe forget to configure the -Xbootclasspath/p: parameter?");
throw e;
}
ErrorCollector errorCollector = new ErrorCollector();
CeyloncFileManager fileManager = (CeyloncFileManager) compiler.getStandardFileManager(null, null, null);
CeyloncTaskImpl task = (CeyloncTaskImpl) compiler.getTask(null, fileManager, errorCollector, Arrays.asList("-sourcepath", sourceDir, "-sysrep", getSysRepPath(), "-rep", depsDir, "-d", "build/classes-sdk", "-cp", getClassPathAsPath()), moduleNames, null);
Boolean result = task.call();
Assert.assertEquals("Compilation of SDK tests failed:" + errorCollector.getAssertionFailureMessage(), Boolean.TRUE, result);
}
use of org.eclipse.ceylon.compiler.java.test.ErrorCollector in project ceylon by eclipse.
the class CMRTests method testMdlOsgiManifestDisabled.
@Test
public void testMdlOsgiManifestDisabled() throws IOException {
ErrorCollector c = new ErrorCollector();
List<String> options = new ArrayList<String>(defaultOptions.size() + 1);
options.addAll(defaultOptions);
options.add("-noosgi");
assertCompilesOk(c, getCompilerTask(options, c, "modules/osgi/a/module.ceylon", "modules/osgi/a/package.ceylon", "modules/osgi/a/A.ceylon").call2());
final String moduleName = "org.eclipse.ceylon.compiler.java.test.cmr.modules.osgi.a";
final String moduleVersion = "1.1.0";
File carFile = getModuleArchive(moduleName, moduleVersion);
JarFile car = new JarFile(carFile);
ZipEntry manifest = car.getEntry(OsgiUtil.OsgiManifest.MANIFEST_FILE_NAME);
assertNull(manifest);
car.close();
}
use of org.eclipse.ceylon.compiler.java.test.ErrorCollector in project ceylon by eclipse.
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 org.eclipse.ceylon.compiler.java.test.ErrorCollector in project ceylon by eclipse.
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.TRUE, result);
compareErrors(collector.get(Diagnostic.Kind.WARNING), new CompilerError(Kind.WARNING, null, 1, "all-lowercase ASCII module names are recommended"), new CompilerError(Kind.WARNING, null, 2, "project source module import is overridden in module overrides file: 'a/2' overrides 'a/1'"));
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 org.eclipse.ceylon.compiler.java.test.ErrorCollector in project ceylon by eclipse.
the class CMRTests method testMdlMultipleVersionsDuringImport.
@Test
public void testMdlMultipleVersionsDuringImport() {
// Compile module A/1
Boolean result = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules/multiversion/a1"), "modules/multiversion/a1/a/module.ceylon", "modules/multiversion/a1/a/package.ceylon", "modules/multiversion/a1/a/A.ceylon").call();
Assert.assertEquals(Boolean.TRUE, result);
// Compile module A/2
result = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules/multiversion/a2"), "modules/multiversion/a2/a/module.ceylon", "modules/multiversion/a2/a/package.ceylon", "modules/multiversion/a2/a/A.ceylon").call();
Assert.assertEquals(Boolean.TRUE, result);
ErrorCollector collector = new ErrorCollector();
// Compile module cImportsATwice which imports both A/1 and A/2
result = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules/multiversion/c"), collector, "modules/multiversion/c/cImportsATwice/module.ceylon", "modules/multiversion/c/cImportsATwice/C.ceylon").call();
Assert.assertEquals(Boolean.FALSE, result);
compareErrors(collector.get(Diagnostic.Kind.ERROR), new CompilerError(20, "source code imports two different versions of module 'a': version '1' and version '2'"), new CompilerError(22, "duplicate module import: 'a'"));
}
Aggregations