Search in sources :

Example 1 with CeyloncTool

use of com.redhat.ceylon.compiler.java.tools.CeyloncTool in project ceylon-compiler by ceylon.

the class CeylonDocToolTests method compileJavaModule.

private void compileJavaModule(String pathname, String... fileNames) throws Exception {
    CeyloncTool compiler = new CeyloncTool();
    List<String> options = Arrays.asList("-src", pathname, "-out", "build/ceylon-cars", "-cp", CompilerTests.getClassPathAsPath());
    JavacFileManager fileManager = compiler.getStandardFileManager(null, null, null);
    List<String> qualifiedNames = new ArrayList<String>(fileNames.length);
    for (String name : fileNames) {
        qualifiedNames.add(pathname + File.separator + name);
    }
    Iterable<? extends JavaFileObject> fileObjects = fileManager.getJavaFileObjectsFromStrings(qualifiedNames);
    JavacTask task = compiler.getTask(null, null, null, options, null, fileObjects);
    Boolean ret = task.call();
    Assert.assertEquals("Compilation failed", Boolean.TRUE, ret);
}
Also used : JavacFileManager(com.sun.tools.javac.file.JavacFileManager) CeyloncTool(com.redhat.ceylon.compiler.java.tools.CeyloncTool) ArrayList(java.util.ArrayList) JavacTask(com.sun.source.util.JavacTask)

Example 2 with CeyloncTool

use of com.redhat.ceylon.compiler.java.tools.CeyloncTool in project ceylon-compiler by ceylon.

the class CeylonDocToolTests method compile.

private void compile(String pathname, String destDir, String moduleName) throws Exception {
    CeyloncTool compiler = new CeyloncTool();
    List<String> options = Arrays.asList("-src", pathname, "-out", destDir, "-cp", CompilerTests.getClassPathAsPath());
    JavacTask task = compiler.getTask(null, null, null, options, Arrays.asList(moduleName), null);
    Boolean ret = task.call();
    Assert.assertEquals("Compilation failed", Boolean.TRUE, ret);
}
Also used : CeyloncTool(com.redhat.ceylon.compiler.java.tools.CeyloncTool) JavacTask(com.sun.source.util.JavacTask)

Example 3 with CeyloncTool

use of com.redhat.ceylon.compiler.java.tools.CeyloncTool 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);
}
Also used : ArrayList(java.util.ArrayList) CeyloncTool(com.redhat.ceylon.compiler.java.tools.CeyloncTool) ErrorCollector(com.redhat.ceylon.compiler.java.test.ErrorCollector) CeyloncTaskImpl(com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl) File(java.io.File) CeyloncFileManager(com.redhat.ceylon.compiler.java.tools.CeyloncFileManager)

Example 4 with CeyloncTool

use of com.redhat.ceylon.compiler.java.tools.CeyloncTool 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);
}
Also used : ArrayList(java.util.ArrayList) CeyloncTool(com.redhat.ceylon.compiler.java.tools.CeyloncTool) ErrorCollector(com.redhat.ceylon.compiler.java.test.ErrorCollector) CeyloncTaskImpl(com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl) LinkedList(java.util.LinkedList) StringWriter(java.io.StringWriter) File(java.io.File) CeyloncFileManager(com.redhat.ceylon.compiler.java.tools.CeyloncFileManager) Test(org.junit.Test)

Example 5 with CeyloncTool

use of com.redhat.ceylon.compiler.java.tools.CeyloncTool 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);
}
Also used : ArrayList(java.util.ArrayList) CeyloncTool(com.redhat.ceylon.compiler.java.tools.CeyloncTool) ErrorCollector(com.redhat.ceylon.compiler.java.test.ErrorCollector) CeyloncTaskImpl(com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl) File(java.io.File) CeyloncFileManager(com.redhat.ceylon.compiler.java.tools.CeyloncFileManager)

Aggregations

CeyloncTool (com.redhat.ceylon.compiler.java.tools.CeyloncTool)8 ArrayList (java.util.ArrayList)7 CeyloncFileManager (com.redhat.ceylon.compiler.java.tools.CeyloncFileManager)6 File (java.io.File)6 CeyloncTaskImpl (com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl)5 ErrorCollector (com.redhat.ceylon.compiler.java.test.ErrorCollector)3 Test (org.junit.Test)3 JavacTask (com.sun.source.util.JavacTask)2 LinkedList (java.util.LinkedList)2 JavacFileManager (com.sun.tools.javac.file.JavacFileManager)1 FileFilter (java.io.FileFilter)1 StringWriter (java.io.StringWriter)1 Ignore (org.junit.Ignore)1