use of com.redhat.ceylon.compiler.java.test.ErrorCollector in project ceylon-compiler by ceylon.
the class MiscTests method compileSDKOnly.
private void compileSDKOnly(String[] modules, String[] extraModules) {
String sourceDir = "../ceylon-sdk/source";
// 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) {
moduleNames.add("ceylon." + module);
}
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, "-d", "build/classes-sdk", "-suppress-warnings", "ceylonNamespace", "-cp", getClassPathAsPath()), moduleNames, null);
Boolean result = task.call();
Assert.assertEquals("Compilation of SDK itself failed: " + errorCollector.getAssertionFailureMessage(), Boolean.TRUE, result);
}
use of com.redhat.ceylon.compiler.java.test.ErrorCollector in project ceylon-compiler by ceylon.
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) {
moduleNames.add("test.ceylon." + module);
}
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, "-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 com.redhat.ceylon.compiler.java.test.ErrorCollector in project ceylon-compiler by ceylon.
the class IssuesTests_1500_1999 method testBug1969.
@SuppressWarnings("deprecation")
@Test
public void testBug1969() {
java.util.List<File> sourceFiles = new ArrayList<File>(1);
sourceFiles.add(new File(getPackagePath(), "bug19xx/Bug1969.ceylon"));
CeyloncTool runCompiler = makeCompiler();
StringWriter writer = new StringWriter();
CeyloncFileManager runFileManager = (CeyloncFileManager) runCompiler.getStandardFileManager(writer, null, null, null);
// make sure the destination repo exists
new File(destDir).mkdirs();
List<String> options = new LinkedList<String>();
options.addAll(defaultOptions);
if (!options.contains("-src"))
options.addAll(Arrays.asList("-src", getSourcePath()));
if (!options.contains("-cacherep"))
options.addAll(Arrays.asList("-cacherep", getCachePath()));
if (!options.contains("-cp"))
options.addAll(Arrays.asList("-cp", getClassPathAsPath()));
options.add("-verbose");
Iterable<? extends JavaFileObject> compilationUnits1 = runFileManager.getJavaFileObjectsFromFiles(sourceFiles);
CeyloncTaskImpl task = runCompiler.getTask(writer, runFileManager, null, options, null, compilationUnits1);
ErrorCollector collector = new ErrorCollector();
assertCompilesOk(collector, task.call2());
Assert.assertTrue(writer.toString().length() > 0);
}
use of com.redhat.ceylon.compiler.java.test.ErrorCollector in project ceylon-compiler by ceylon.
the class CMRTests method testMdlCeylonAetherDependencyConflict.
@Test
public void testMdlCeylonAetherDependencyConflict() throws IOException {
// Try to compile the ceylon module
CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir, "-verbose:cmr"), (DiagnosticListener<? super FileObject>) null, "modules/ceylonAetherConflict2/module.ceylon");
assertEquals(Boolean.TRUE, ceylonTask.call());
ErrorCollector collector = new ErrorCollector();
ceylonTask = getCompilerTask(Arrays.asList("-out", destDir, "-verbose:cmr"), collector, "modules/ceylonAetherConflict/module.ceylon", "modules/ceylonAetherConflict/foo.ceylon");
assertEquals(Boolean.TRUE, ceylonTask.call());
compareErrors(collector.get(Diagnostic.Kind.WARNING), new CompilerError(Diagnostic.Kind.WARNING, null, 21, "source code imports two different versions of similar modules 'org.apache.httpcomponents.httpclient/4.3.2' and 'org.apache.httpcomponents:httpclient/4.3.3'"), new CompilerError(Diagnostic.Kind.WARNING, null, 21, "module (transitively) imports conflicting versions of similar dependencies 'org.apache.httpcomponents.httpclient/4.3.2' and 'org.apache.httpcomponents:httpclient/4.3.3'"));
}
use of com.redhat.ceylon.compiler.java.test.ErrorCollector in project ceylon-compiler by ceylon.
the class CMRTests method testMdlMultipleVersionsDuringImplicitImport.
@Test
public void testMdlMultipleVersionsDuringImplicitImport() {
// 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);
// Compile module bExportsA1/1
result = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules/multiversion/b"), "modules/multiversion/b/bExportsA1/module.ceylon", "modules/multiversion/b/bExportsA1/package.ceylon", "modules/multiversion/b/bExportsA1/B.ceylon").call();
Assert.assertEquals(Boolean.TRUE, result);
// Compile module cImportsABIndirectlyFail which imports both A/1 and A/2
ErrorCollector collector = new ErrorCollector();
result = getCompilerTask(Arrays.asList("-src", getPackagePath() + "/modules/multiversion/c"), collector, "modules/multiversion/c/cImportsABIndirectlyFail/module.ceylon", "modules/multiversion/c/cImportsABIndirectlyFail/C.ceylon").call();
Assert.assertEquals(Boolean.FALSE, result);
compareErrors(collector.get(Diagnostic.Kind.ERROR), new CompilerError(20, "module (transitively) imports conflicting versions of dependency 'a': version '1' and version '2'"), new CompilerError(20, "source code imports two different versions of module 'a': version '1' and version '2'"));
}
Aggregations