Search in sources :

Example 26 with N4jscBase

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

the class N4jscBasicTest method testMainDebugHelp.

/**
 * Test debug output before help. This test doesn't run a compile because of the "-help" option should end
 * execution.
 */
@Test
public void testMainDebugHelp() throws ExitCodeException {
    String[] args = { "--debug", "--help" };
    SuccessExitStatus status = new N4jscBase().doMain(args);
    assertEquals("Should have printed help and exited with success.", SuccessExitStatus.INSTANCE.code, status.code);
}
Also used : SuccessExitStatus(org.eclipse.n4js.hlc.base.SuccessExitStatus) N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 27 with N4jscBase

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

the class N4jscBasicTest method testCompileP1_And_Run_A_WithNodeRunner.

/**
 * Simple test of compiling a project and running a class from that compiled code with NODEJS.
 */
@Test
public void testCompileP1_And_Run_A_WithNodeRunner() throws ExitCodeException {
    String proot = workspace.getAbsolutePath().toString();
    // Project
    String projectP1 = "P1";
    String pathToP1 = proot + "/" + projectP1;
    // absolute src filename
    String fileA = proot + "/" + projectP1 + "/src/A.n4js";
    String[] args = { "-pl", proot, "--buildType", "projects", pathToP1, "--runWith", "nodejs", "--run", fileA, "--verbose" };
    SuccessExitStatus status = new N4jscBase().doMain(args);
    assertEquals("Should exit with success", SuccessExitStatus.INSTANCE.code, status.code);
}
Also used : SuccessExitStatus(org.eclipse.n4js.hlc.base.SuccessExitStatus) N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 28 with N4jscBase

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

the class N4jscTestersTest method testCompileAllProjectsGenerateTestCatalog_relativePath.

/**
 * Gathers all tests from the workspace and generates a test catalog (given as relative path).
 */
@Test
public void testCompileAllProjectsGenerateTestCatalog_relativePath() throws ExitCodeException, FileNotFoundException, IOException {
    String proot = workspace.getAbsolutePath().toString();
    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)

Example 29 with N4jscBase

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

the class N4jscTestersTest method testCompile_And_LaunchSingleIgnoredTestFile.

/**
 * Simple test of compiling a project and execute tests from <u>a single test file</u>.
 *
 * @throws ExitCodeException
 *             in error cases ( not expected )
 */
@Test
public void testCompile_And_LaunchSingleIgnoredTestFile() throws ExitCodeException {
    String proot = workspace.getAbsolutePath().toString();
    // Project
    String projectDemoTest = "DemoTest";
    String pathToDemoTest = proot + "/" + projectDemoTest;
    // absolute src filename
    String fileFooTest = pathToDemoTest + "/test/BazTest.n4js";
    String[] args = { "--projectlocations", proot, "--buildType", "allprojects", "--testWith", "nodejs_mangelhaft", "--test", fileFooTest, "--verbose" };
    new N4jscBase().doMain(args);
// TODO add proper assertion that test was actually executed properly!!!
}
Also used : N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 30 with N4jscBase

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

the class N4jscTestersTest method testCompile_And_LaunchSinglePassingTestFile.

/**
 * Simple test of compiling a project and execute tests from <u>a single test file</u>.
 *
 * @throws ExitCodeException
 *             in error cases ( not expected )
 */
@Test
public void testCompile_And_LaunchSinglePassingTestFile() throws ExitCodeException {
    String proot = workspace.getAbsolutePath().toString();
    // Project
    String projectDemoTest = "DemoTest";
    String pathToDemoTest = proot + "/" + projectDemoTest;
    // absolute src filename
    String fileFooTest = pathToDemoTest + "/test/FooTest.n4js";
    String[] args = { "--projectlocations", proot, "--buildType", "allprojects", "--testWith", "nodejs_mangelhaft", "--test", fileFooTest, "--verbose" };
    new N4jscBase().doMain(args);
// TODO add proper assertion that test was actually executed properly!!!
}
Also used : 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