Search in sources :

Example 6 with CliTools

use of org.eclipse.n4js.cli.helper.CliTools in project n4js by eclipse.

the class BuildN4jsLibs method installDependencies.

private static void installDependencies(Path n4jsLibsRootPath) {
    CliTools cliTools = new CliTools();
    cliTools.setInheritIO(true);
    cliTools.setEnvironmentVariable("NPM_TOKEN", "dummy");
    cliTools.yarnInstall(n4jsLibsRootPath);
}
Also used : CliTools(org.eclipse.n4js.cli.helper.CliTools)

Example 7 with CliTools

use of org.eclipse.n4js.cli.helper.CliTools in project n4js by eclipse.

the class BuildN4jsLibs method compile.

private static void compile(Path n4jsLibsRootPath) {
    CliCompileResult compileResult = new CliCompileResult();
    try {
        CliTools cliTools = new CliTools();
        cliTools.setInheritIO(true);
        // we want '--clean' but *not* '--noPersist'
        N4jscTestOptions options = COMPILE(false, n4jsLibsRootPath.toFile()).clean();
        Preconditions.checkState(options.isClean());
        Preconditions.checkState(!options.isNoPersist());
        cliTools.callN4jscInprocess(options, false, compileResult);
    } catch (CliException e) {
        if (compileResult.getException() != null) {
            throw new RuntimeException(compileResult.getException());
        } else if (compileResult.getErrs() > 0) {
            // case to suppress further error reporting:
            throw new RuntimeException("Errors while compiling n4js-libs");
        } else {
            throw new RuntimeException(e);
        }
    } catch (Exception e) {
        println("EXCEPTION while compiling n4js-libs:");
        e.printStackTrace();
        Throwable root = Throwables.getRootCause(e);
        if (root != e) {
            println("Root cause:");
            root.printStackTrace();
        }
        Throwables.throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
Also used : CliCompileResult(org.eclipse.n4js.cli.helper.CliCompileResult) CliException(org.eclipse.n4js.cli.helper.CliTools.CliException) N4jscTestOptions(org.eclipse.n4js.cli.N4jscTestOptions) CliTools(org.eclipse.n4js.cli.helper.CliTools) CliException(org.eclipse.n4js.cli.helper.CliTools.CliException) IOException(java.io.IOException)

Example 8 with CliTools

use of org.eclipse.n4js.cli.helper.CliTools in project n4js by eclipse.

the class N4jsLibsTest method testN4jsLibs.

/**
 */
@Test
public void testN4jsLibs() throws IOException {
    final Path n4jsRootPath = UtilN4.findN4jsRepoRootPath();
    final Path n4jsLibsRootPath = n4jsRootPath.resolve(N4JSGlobals.N4JS_LIBS_FOLDER_NAME);
    final Path testReportPath = n4jsLibsRootPath.resolve("build").resolve("report.xml");
    Files.deleteIfExists(testReportPath);
    CliTools cliTools = new CliTools();
    cliTools.setInheritIO(true);
    ProcessResult result = cliTools.yarnRun(n4jsLibsRootPath, "run", "test");
    assertEquals("non-zero exit code", 0, result.getExitCode());
    assertTrue("test report not found", Files.isRegularFile(testReportPath));
}
Also used : Path(java.nio.file.Path) ProcessResult(org.eclipse.n4js.cli.helper.ProcessResult) CliTools(org.eclipse.n4js.cli.helper.CliTools) Test(org.junit.Test)

Example 9 with CliTools

use of org.eclipse.n4js.cli.helper.CliTools in project n4js by eclipse.

the class AbstractCliFrontendTest method doN4jsc.

@Override
protected void doN4jsc(String[] args, boolean ignoreFailure, boolean removeUsage, CliCompileResult result) {
    CliTools cliTools = new CliTools();
    cliTools.setIgnoreFailure(ignoreFailure);
    cliTools.callN4jscFrontendInprocess(args, removeUsage, result);
}
Also used : CliTools(org.eclipse.n4js.cli.helper.CliTools)

Aggregations

CliTools (org.eclipse.n4js.cli.helper.CliTools)9 ProcessResult (org.eclipse.n4js.cli.helper.ProcessResult)5 File (java.io.File)3 Path (java.nio.file.Path)3 CliException (org.eclipse.n4js.cli.helper.CliTools.CliException)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 N4jscTestOptions (org.eclipse.n4js.cli.N4jscTestOptions)1 CliCompileResult (org.eclipse.n4js.cli.helper.CliCompileResult)1 Project (org.eclipse.n4js.tests.codegen.Project)1 FileURI (org.eclipse.n4js.workspace.locations.FileURI)1 Xpect (org.eclipse.xpect.runner.Xpect)1