Search in sources :

Example 11 with N4jscBase

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

the class TargetPlatformConfigurationsTest method testCompileCleanInstallLocation.

/**
 * Test cleaning install location.
 *
 * @throws ExitCodeException
 *             propagated from compiler in case of issues
 */
@Test
public void testCompileCleanInstallLocation() throws IOException, ExitCodeException {
    final String wsRoot = workspace.getAbsolutePath().toString();
    // force creating install location
    File testFile = new File(getTargetPlatformInstallLocation(), "tst.txt");
    testFile.createNewFile();
    assertTrue("setup error, test file should exist yet at " + testFile.getAbsolutePath(), testFile.exists());
    final String[] args = { "--clean", "--targetPlatformInstallLocation", getTargetPlatformInstallLocation().getAbsolutePath(), "--verbose", "--projectlocations", wsRoot, "--buildType", BuildType.allprojects.toString() };
    SuccessExitStatus status = new N4jscBase().doMain(args);
    assertEquals("Should exit with success", SuccessExitStatus.INSTANCE.code, status.code);
    assertFalse("install location was not cleaned, test file exists at " + testFile.getAbsolutePath(), testFile.exists());
}
Also used : SuccessExitStatus(org.eclipse.n4js.hlc.base.SuccessExitStatus) File(java.io.File) N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 12 with N4jscBase

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

the class TargetPlatformConfigurationsTest method testCompileCreatesInstallLocation.

/**
 * Test creating install location.
 *
 * @throws ExitCodeException
 *             propagated from compiler in case of issues
 */
@Test
public void testCompileCreatesInstallLocation() throws IOException, ExitCodeException {
    final String wsRoot = workspace.getAbsolutePath().toString();
    // force creating install location
    FileDeleter.delete(getTargetPlatformInstallLocation());
    final String[] args = { "--installMissingDependencies", "--targetPlatformInstallLocation", getTargetPlatformInstallLocation().getAbsolutePath(), "--verbose", "--projectlocations", wsRoot, "--buildType", BuildType.allprojects.toString() };
    SuccessExitStatus status = new N4jscBase().doMain(args);
    assertEquals("Should exit with success", SuccessExitStatus.INSTANCE.code, status.code);
    assertTrue("install location was not created", getTargetPlatformInstallLocation().exists());
}
Also used : SuccessExitStatus(org.eclipse.n4js.hlc.base.SuccessExitStatus) N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 13 with N4jscBase

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

the class AT_IDEBUG_695_CannotSetFinalFieldInCtorForStaticPolyfillsTest method compileCheckFinalFieldCanBeSetInInheritedCtor_ExpectCanBeSet.

/**
 */
@Test
public void compileCheckFinalFieldCanBeSetInInheritedCtor_ExpectCanBeSet() 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-695/src/Main.n4js";
    final String[] args = { "--projectlocations", wsRoot, "--buildType", "dontcompile", "--runWith", "nodejs", "--run", fileToRun, "--verbose" };
    // Run
    final String out = runAndCaptureOutput(args);
    N4CliHelper.assertExpectedOutput("A.a == 5: true", out);
}
Also used : N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 14 with N4jscBase

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

the class N4jscTestersTest method testCompileAllProjectsGenerateTestCatalog_absolutePath.

/**
 * Gathers all tests from the workspace and generates a test catalog (given as absolute path).
 */
@Test
public void testCompileAllProjectsGenerateTestCatalog_absolutePath() throws ExitCodeException, FileNotFoundException, IOException {
    String proot = workspace.getAbsolutePath().toString();
    final File tempDir = Files.createTempDir();
    tempDir.deleteOnExit();
    final String[] args = { "--projectlocations", proot, "--buildType", "allprojects", "--testCatalogFile", tempDir + "/test-catalog.json", "--verbose" };
    new N4jscBase().doMain(args);
    final File file = new File(tempDir + "/test-catalog.json");
    file.deleteOnExit();
    final String actual = new String(java.nio.file.Files.readAllBytes(Paths.get(file.toURI())));
    assertEquals(EXPECTED_TEST_CATALOG, actual);
}
Also used : File(java.io.File) N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 15 with N4jscBase

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

the class N4jscTestersTest method testCompileAllProjectsGenerateTestCatalog_existingRelativePath.

/**
 * Gathers all tests from the workspace and generates a test catalog into an existing file (given as relative path).
 */
@Test
public void testCompileAllProjectsGenerateTestCatalog_existingRelativePath() throws ExitCodeException, FileNotFoundException, IOException {
    String proot = workspace.getAbsolutePath().toString();
    final File existingFile = new File("test-catalog.json");
    existingFile.createNewFile();
    existingFile.deleteOnExit();
    final String[] args = { "--projectlocations", proot, "--buildType", "allprojects", "--testCatalogFile", "test-catalog.json", "--verbose" };
    new N4jscBase().doMain(args);
    final File file = new File("test-catalog.json");
    file.deleteOnExit();
    final String actual = new String(java.nio.file.Files.readAllBytes(Paths.get(file.toURI())));
    assertEquals(EXPECTED_TEST_CATALOG, actual);
}
Also used : File(java.io.File) N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

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