Search in sources :

Example 16 with N4jscBase

use of org.eclipse.n4js.hlc.base.N4jscBase in project n4js by eclipse.

the class AT_GHOLD_212_transpilecrashTest method testCompileOfExtendedIterator_from_RuntimeLibrary.

/**
 * The Problem was, that nothing was compiled.
 */
@Test
public void testCompileOfExtendedIterator_from_RuntimeLibrary() throws ExitCodeException {
    String proot = workspace.getAbsolutePath().toString();
    String[] args = { "--projectlocations", proot, "--buildType", "allprojects", "--verbose" };
    // compile
    new N4jscBase().doMain(args);
    // Make sure, we get here and have exactly one file compiled:
    assertFilesCompiledToES(1, proot);
}
Also used : N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 17 with N4jscBase

use of org.eclipse.n4js.hlc.base.N4jscBase in project n4js by eclipse.

the class AT_IDEBUG_542_missing_dep_to_project_under_testTest method testCompileOfExtendedIterator_from_RuntimeLibrary.

/**
 * The Problem was, that nothing was compiled.
 */
@Test
public void testCompileOfExtendedIterator_from_RuntimeLibrary() throws ExitCodeException {
    String proot = workspace.getAbsolutePath().toString();
    String[] args = { "--projectlocations", proot, "--buildType", "allprojects", "--verbose" };
    // compile
    new N4jscBase().doMain(args);
    // Make sure, we get here and have exactly two files compiled:
    assertFilesCompiledToES(2, proot);
}
Also used : N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 18 with N4jscBase

use of org.eclipse.n4js.hlc.base.N4jscBase in project n4js by eclipse.

the class AT_IDEBUG_654_MissingPolyfillImportsTest method compileCheckPolyfillImports_ExpectExist.

/**
 */
@Test
public void compileCheckPolyfillImports_ExpectExist() throws ExitCodeException, IOException {
    // pre compile
    final String wsRoot = workspace.getAbsolutePath().toString();
    // Compile
    final String[] args_precompile = { "--projectlocations", wsRoot, "--buildType", "allprojects", "--verbose" };
    new N4jscBase().doMain(args_precompile);
    // run without compile
    final String fileToRun = wsRoot + "/IDEBUG-654_2/src/Main.n4js";
    final String[] args = { "--projectlocations", wsRoot, "--buildType", "dontcompile", "--runWith", "nodejs", "--run", fileToRun, "--verbose" };
    // Run
    final String out = runAndCaptureOutput(args);
    N4CliHelper.assertExpectedOutput("functionFromModuleA\n" + "variableFromModuleB\n" + "variableFromModuleC\n" + "variableFromModuleC", out);
}
Also used : N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 19 with N4jscBase

use of org.eclipse.n4js.hlc.base.N4jscBase in project n4js by eclipse.

the class AbstractN4jscTest method runAndCaptureOutput.

/**
 * Runs N4JSC with the given arguments.
 *
 * Captures the output (stdout + stderr) of the executed runner and returns it as a string.
 *
 * This does not include the output of N4JSC itself.
 *
 * @param arguments
 *            The arguments to pass to {@link N4jscBase#doMain(String...)}
 *
 * @return The command output. stderr + stdout concatenated in that order.
 *
 * @throws ExitCodeException
 *             If N4JSC exists with a non-zero exist code
 * @throws IOException
 *             If the creation of intermediate log files fails.
 */
protected static String runAndCaptureOutput(String[] arguments) throws ExitCodeException, IOException {
    boolean errors = true;
    boolean keepOutputForDebug = true;
    File errorFile = File.createTempFile("run_err", null);
    File outputFile = File.createTempFile("run_out", null);
    try {
        if (!keepOutputForDebug) {
            errorFile.deleteOnExit();
            outputFile.deleteOnExit();
        } else {
            System.out.println("Errors: " + errorFile + "    Ouput: " + outputFile);
        }
        setOutputfileSystemProperties(errorFile.getAbsolutePath(), outputFile.getAbsolutePath());
        new N4jscBase().doMain(arguments);
        // cleanup properties.
        setOutputfileSystemProperties("", "");
        // read the files, concat & return string.
        return N4CliHelper.readLogfile(errorFile) + N4CliHelper.readLogfile(outputFile);
    } finally {
        if (errors) {
            if (outputFile.canRead()) {
                String readLogfile = N4CliHelper.readLogfile(outputFile);
                if (!Strings.isNullOrEmpty(readLogfile))
                    System.out.println(readLogfile);
            }
            if (errorFile.canRead()) {
                String readLogfile = N4CliHelper.readLogfile(errorFile);
                if (!Strings.isNullOrEmpty(readLogfile))
                    System.out.println(readLogfile);
            }
        }
        if (outputFile.exists())
            FileUtils.deleteFileOrFolder(outputFile);
        if (errorFile.exists())
            FileUtils.deleteFileOrFolder(errorFile);
    }
}
Also used : File(java.io.File) N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase)

Example 20 with N4jscBase

use of org.eclipse.n4js.hlc.base.N4jscBase in project n4js by eclipse.

the class IncompleteApiImplementationTest method compileAPI_And_API_Impl.

/**
 * Setup workspace with api & api-impl & compile
 */
/**
 * Upfront compilation when loading this test-class.
 */
public void compileAPI_And_API_Impl() throws ExitCodeException {
    proot = workspace.getAbsolutePath().toString();
    project_one_api_execution = "one.api.execution";
    pathTo_one_api_execution = proot + "/" + project_one_api_execution;
    String[] args = { "--projectlocations", proot, "--buildType", "allprojects", "--verbose" };
    new N4jscBase().doMain(args);
}
Also used : N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase)

Aggregations

N4jscBase (org.eclipse.n4js.hlc.base.N4jscBase)34 Test (org.junit.Test)31 SuccessExitStatus (org.eclipse.n4js.hlc.base.SuccessExitStatus)9 File (java.io.File)6 IOException (java.io.IOException)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Optional (com.google.common.base.Optional)1 Injector (com.google.inject.Injector)1 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileWriter (java.io.FileWriter)1 InputStreamReader (java.io.InputStreamReader)1 PrintStream (java.io.PrintStream)1 Reader (java.io.Reader)1 FileVisitResult (java.nio.file.FileVisitResult)1 FileVisitor (java.nio.file.FileVisitor)1