use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl 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.tools.CeyloncTaskImpl 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.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.
the class MiscTests method compileRuntime.
@Test
public void compileRuntime() {
cleanCars("build/classes-runtime");
java.util.List<File> sourceFiles = new ArrayList<File>();
String ceylonSourcePath = "../ceylon.language/src";
String javaSourcePath = "../ceylon.language/runtime";
String[] ceylonPackages = { "ceylon.language", "ceylon.language.meta", "ceylon.language.impl", "ceylon.language.meta.declaration", "ceylon.language.meta.model", "ceylon.language.serialization" };
// Native files
FileFilter exceptions = new FileFilter() {
@Override
public boolean accept(File pathname) {
String filename = pathname.getName();
filename = filename.substring(0, filename.lastIndexOf('.'));
for (String s : new String[] { "Boolean", "Integer", "Float", "Character", "String", "Byte", "Array", "Tuple", "Exception", "AssertionError", "Callable", "flatten", "className", "integerRangeByIterable", "modules", "printStackTrace", "process", "Throwable", "type", "typeLiteral", "classDeclaration", "reach", "unflatten", "serialization", "PartialImpl" }) {
if (s.equals(filename)) {
return true;
}
}
if (filename.equals("annotations") && pathname.getParentFile().getName().equals("meta")) {
return true;
}
return false;
}
};
String[] extras = new String[] { "true", "false" };
String[] modelExtras = new String[] { "classDeclaration", "annotations", "modules", "type", "typeLiteral" };
String[] s11nExtras = new String[] { "PartialImpl" };
for (String pkg : ceylonPackages) {
File pkgDir = new File(ceylonSourcePath, pkg.replaceAll("\\.", "/"));
File javaPkgDir = new File(javaSourcePath, pkg.replaceAll("\\.", "/"));
File[] files = pkgDir.listFiles();
if (files != null) {
for (File src : files) {
if (src.isFile() && src.getName().toLowerCase().endsWith(".ceylon")) {
String baseName = src.getName().substring(0, src.getName().length() - 7);
if (!exceptions.accept(src)) {
sourceFiles.add(src);
} else {
addJavaSourceFile(baseName, sourceFiles, javaPkgDir, false);
}
}
}
}
}
// add extra files that are in Java
File javaPkgDir = new File(javaSourcePath, "ceylon/language");
for (String extra : extras) addJavaSourceFile(extra, sourceFiles, javaPkgDir, true);
File javaModelPkgDir = new File(javaSourcePath, "ceylon/language/meta");
for (String extra : modelExtras) addJavaSourceFile(extra, sourceFiles, javaModelPkgDir, true);
File javaS11nPkgDir = new File(javaSourcePath, "ceylon/language/serialization");
for (String extra : s11nExtras) addJavaSourceFile(extra, sourceFiles, javaS11nPkgDir, true);
File javaS11nEPkgDir = new File(javaSourcePath, "ceylon/language/impl");
for (String extra : new String[] { "reach" }) addJavaSourceFile(extra, sourceFiles, javaS11nEPkgDir, true);
String[] javaPackages = { "com/redhat/ceylon/compiler/java", "com/redhat/ceylon/compiler/java/language", "com/redhat/ceylon/compiler/java/metadata", "com/redhat/ceylon/compiler/java/runtime/ide", "com/redhat/ceylon/compiler/java/runtime/metamodel", "com/redhat/ceylon/compiler/java/runtime/model", "com/redhat/ceylon/compiler/java/runtime/metamodel/decl", "com/redhat/ceylon/compiler/java/runtime/metamodel/meta", "com/redhat/ceylon/compiler/java/runtime/serialization" };
for (String pkg : javaPackages) {
File pkgDir = new File(javaSourcePath, pkg.replaceAll("\\.", "/"));
File[] files = pkgDir.listFiles();
if (files != null) {
for (File src : files) {
if (src.isFile() && src.getName().toLowerCase().endsWith(".java")) {
sourceFiles.add(src);
}
}
}
}
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;
}
CeyloncFileManager fileManager = (CeyloncFileManager) compiler.getStandardFileManager(null, null, null);
Iterable<? extends JavaFileObject> compilationUnits1 = fileManager.getJavaFileObjectsFromFiles(sourceFiles);
String compilerSourcePath = ceylonSourcePath + File.pathSeparator + javaSourcePath;
CeyloncTaskImpl task = (CeyloncTaskImpl) compiler.getTask(null, fileManager, null, Arrays.asList("-sourcepath", compilerSourcePath, "-d", "build/classes-runtime", "-Xbootstrapceylon", "-cp", getClassPathAsPathExcludingLanguageModule(), "-suppress-warnings", "ceylonNamespace"), null, compilationUnits1);
Boolean result = task.call();
Assert.assertEquals("Compilation failed", Boolean.TRUE, result);
}
use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.
the class CMRTests method testMdlImplicitAetherDependencyDefault.
@Test
public void testMdlImplicitAetherDependencyDefault() throws IOException {
// Try to compile the ceylon module
CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir, "-verbose:cmr"), (DiagnosticListener<? super FileObject>) null, "modules/aetherdefault/module.ceylon", "modules/aetherdefault/foo.ceylon");
assertEquals(Boolean.TRUE, ceylonTask.call());
// We're assuming a standard Maven configuration here!
File camelJar = new File(System.getProperty("user.home"), ".m2/repository/org/apache/camel/camel-core/2.9.2/camel-core-2.9.2.jar");
assertTrue(camelJar.exists());
}
use of com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl in project ceylon-compiler by ceylon.
the class CMRTests method testMdlSuppressObsoleteClasses.
@Test
public void testMdlSuppressObsoleteClasses() throws IOException {
File sourceFile = new File(getPackagePath(), "modules/single/SuppressClass.ceylon");
copy(new File(getPackagePath(), "modules/single/SuppressClass_1.ceylon"), sourceFile);
CeyloncTaskImpl compilerTask = getCompilerTask("modules/single/module.ceylon", "modules/single/SuppressClass.ceylon");
Boolean success = compilerTask.call();
assertTrue(success);
File carFile = getModuleArchive("com.redhat.ceylon.compiler.java.test.cmr.modules.single", "6.6.6");
assertTrue(carFile.exists());
ZipFile car = new ZipFile(carFile);
ZipEntry oneClass = car.getEntry("com/redhat/ceylon/compiler/java/test/cmr/modules/single/One.class");
assertNotNull(oneClass);
ZipEntry twoClass = car.getEntry("com/redhat/ceylon/compiler/java/test/cmr/modules/single/Two.class");
assertNotNull(twoClass);
car.close();
copy(new File(getPackagePath(), "modules/single/SuppressClass_2.ceylon"), sourceFile);
compilerTask = getCompilerTask("modules/single/module.ceylon", "modules/single/SuppressClass.ceylon");
success = compilerTask.call();
assertTrue(success);
carFile = getModuleArchive("com.redhat.ceylon.compiler.java.test.cmr.modules.single", "6.6.6");
assertTrue(carFile.exists());
car = new ZipFile(carFile);
oneClass = car.getEntry("com/redhat/ceylon/compiler/java/test/cmr/modules/single/One.class");
assertNotNull(oneClass);
twoClass = car.getEntry("com/redhat/ceylon/compiler/java/test/cmr/modules/single/Two.class");
assertNull(twoClass);
car.close();
sourceFile.delete();
}
Aggregations