Search in sources :

Example 6 with CliCompileResult

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

the class N4jscCleanTest method testCompileThenClean.

/**
 * Basic compile test.
 */
@Test
public void testCompileThenClean() {
    CliCompileResult compileResult = n4jsc(COMPILE(workspace), VALIDATION_ERRORS);
    assertEquals(compileResult.toString(), 4, compileResult.getTranspiledFilesCount());
    CliCompileResult cleanResult = n4jsc(CLEAN(workspace));
    assertEquals(cleanResult.toString(), 8, cleanResult.getDeletedFilesCount());
}
Also used : CliCompileResult(org.eclipse.n4js.cli.helper.CliCompileResult) AbstractCliCompileTest(org.eclipse.n4js.cli.helper.AbstractCliCompileTest) Test(org.junit.Test)

Example 7 with CliCompileResult

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

the class N4jscTestCatalogIgnoresTestsInNodeModulesTest method testCompileAndAssertTestCatalog.

/**
 * Compile and check if test catalog exists.
 */
@Test
public void testCompileAndAssertTestCatalog() throws Exception {
    File testCatalog = new File(projectRoot, N4JSGlobals.TEST_CATALOG);
    CliCompileResult cliResult = n4jsc(COMPILE(workspace), VALIDATION_ERRORS);
    assertEquals(cliResult.toString(), 1, cliResult.getTranspiledFilesCount());
    assertFalse("Superfluous test catalog in P1", testCatalog.isFile());
}
Also used : CliCompileResult(org.eclipse.n4js.cli.helper.CliCompileResult) File(java.io.File) Test(org.junit.Test) AbstractCliCompileTest(org.eclipse.n4js.cli.helper.AbstractCliCompileTest)

Example 8 with CliCompileResult

use of org.eclipse.n4js.cli.helper.CliCompileResult 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() {
    File proot = new File(workspace, PACKAGES);
    N4jscOptions options = COMPILE(proot);
    CliCompileResult cliResult = n4jsc(options, VALIDATION_ERRORS);
    // Make sure, we get here and have exactly two files compiled:
    assertEquals(cliResult.toString(), 0, cliResult.getTranspiledFilesCount(proot.toPath().resolve("APIx")));
    assertEquals(cliResult.toString(), 2, cliResult.getTranspiledFilesCount(proot.toPath().resolve("APIx-test")));
}
Also used : CliCompileResult(org.eclipse.n4js.cli.helper.CliCompileResult) N4jscOptions(org.eclipse.n4js.cli.N4jscOptions) File(java.io.File) Test(org.junit.Test) AbstractCliCompileTest(org.eclipse.n4js.cli.helper.AbstractCliCompileTest)

Example 9 with CliCompileResult

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

the class AT_IDEBUG_654_MissingPolyfillImportsTest method compileCheckPolyfillImports_ExpectExist.

/**
 */
@Test
public void compileCheckPolyfillImports_ExpectExist() {
    Path projectDir = workspace.toPath().resolve(WS_IDEBUG_654_2);
    Path fileToRun = projectDir.resolve("src-gen/Main.js");
    N4jscOptions options = COMPILE(workspace);
    CliCompileResult cliResult = n4jsc(options, VALIDATION_ERRORS);
    assertEquals(cliResult.toString(), 5, cliResult.getTranspiledFilesCount());
    ProcessResult nodejsResult = nodejsRun(projectDir, fileToRun);
    assertEquals(nodejsResult.toString(), "functionFromModuleA\n" + "variableFromModuleB\n" + "variableFromModuleC\n" + "variableFromModuleC", nodejsResult.getStdOut());
}
Also used : Path(java.nio.file.Path) CliCompileResult(org.eclipse.n4js.cli.helper.CliCompileResult) N4jscOptions(org.eclipse.n4js.cli.N4jscOptions) ProcessResult(org.eclipse.n4js.cli.helper.ProcessResult) Test(org.junit.Test) AbstractCliCompileTest(org.eclipse.n4js.cli.helper.AbstractCliCompileTest)

Example 10 with CliCompileResult

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

the class N4jscBasicTest method testBuildDependentFilesIfFileReadded.

/**
 * Test a second run of the compiler after a file was added to fix compile problems
 */
@Test
public void testBuildDependentFilesIfFileReadded() throws Exception {
    N4jscTestOptions compileOptions = COMPILE(DONT_CLEAN, workspace);
    CliCompileResult firstRun = n4jsc(compileOptions, SUCCESS);
    assertEquals(firstRun.toString(), 20, firstRun.getTranspiledFilesCount());
    Path fileCn4js = proot.toPath().resolve("P1/src/c/C.n4js");
    byte[] bytesC = Files.readAllBytes(fileCn4js);
    Files.delete(fileCn4js);
    n4jsc(compileOptions, VALIDATION_ERRORS);
    // Y.n4js depends on C.n4js
    File fileCjs = proot.toPath().resolve("P1/src-gen/c/C.js").toFile();
    assertFalse(fileCjs.exists());
    File fileYjs = proot.toPath().resolve("P1/src-gen/y/Y.js").toFile();
    assertFalse(fileYjs.exists());
    Files.write(fileCn4js, bytesC);
    CliCompileResult thirdRun = n4jsc(compileOptions, SUCCESS);
    assertTrue(fileCjs.exists());
    assertTrue(fileYjs.exists());
    assertOutputEqual(firstRun, thirdRun);
}
Also used : Path(java.nio.file.Path) CliCompileResult(org.eclipse.n4js.cli.helper.CliCompileResult) N4jscTestOptions(org.eclipse.n4js.cli.N4jscTestOptions) File(java.io.File) Test(org.junit.Test) AbstractCliCompileTest(org.eclipse.n4js.cli.helper.AbstractCliCompileTest)

Aggregations

CliCompileResult (org.eclipse.n4js.cli.helper.CliCompileResult)92 Test (org.junit.Test)90 AbstractCliCompileTest (org.eclipse.n4js.cli.helper.AbstractCliCompileTest)41 N4jscTestOptions (org.eclipse.n4js.cli.N4jscTestOptions)22 File (java.io.File)20 Path (java.nio.file.Path)12 ProcessResult (org.eclipse.n4js.cli.helper.ProcessResult)12 N4jscOptions (org.eclipse.n4js.cli.N4jscOptions)8 AbstractCliJarTest (org.eclipse.n4js.cli.helper.AbstractCliJarTest)6 Gson (com.google.gson.Gson)1 JsonObject (com.google.gson.JsonObject)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 CliTools (org.eclipse.n4js.cli.helper.CliTools)1 CliException (org.eclipse.n4js.cli.helper.CliTools.CliException)1 Ignore (org.junit.Ignore)1