Search in sources :

Example 21 with N4jscBase

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

the class N4jscBasicTest method testCleanMultipleProjects.

/**
 * Test that clean removes files in src-gen folder but does not compile when compiling multiple projects.
 */
@Test
public void testCleanMultipleProjects() throws ExitCodeException {
    String proot = workspace.getAbsolutePath().toString();
    String project1 = "TestCleanPrj1";
    String project2 = "TestCleanPrj2";
    String pathToProject1 = proot + "/" + project1;
    String pathToProject2 = proot + "/" + project2;
    String[] args = { "--clean", "--projectlocations", proot, "--buildType", "projects", pathToProject1, pathToProject2 };
    new N4jscBase().doMain(args);
    // 0 = 0 in TestCleanPrj1 + 0 in TestCleanPrj2
    assertEquals(0, countFilesCompiledToES(proot));
}
Also used : N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 22 with N4jscBase

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

the class N4jscBasicTest method testCleanSingleProject.

/**
 * Test that when build type is a single project, if clean flag is on, files in src-gen folder are removed but no
 * files are compiled.
 */
@Test
public void testCleanSingleProject() throws ExitCodeException {
    String proot = workspace.getAbsolutePath().toString();
    String project = "TestCleanPrj1";
    String pathToProject = proot + "/" + project;
    String[] args = { "--debug", "--clean", "--projectlocations", proot, "--buildType", "projects", pathToProject };
    new N4jscBase().doMain(args);
    // 1 = 0 in TestCleanPrj1 + 1 in TestCleanPrj2
    assertEquals(1, countFilesCompiledToES(proot));
}
Also used : N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 23 with N4jscBase

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

the class N4jscBasicTest method testMainArgsCompileAllKeepCompiling.

/**
 * With "keep compiling" compiler does not throw compilation errors.
 */
@Test
public void testMainArgsCompileAllKeepCompiling() throws ExitCodeException {
    String proot = workspace.getAbsolutePath().toString();
    String[] args = { "--projectlocations", proot, "--buildType", "allprojects", "--keepCompiling" };
    new N4jscBase().doMain(args);
    // Assert that at most 19 files are compiled. The actual number depends on the chosen algorithm for the build
    // order and on the order in which the project dependency graph is traversed. 19 is the maximum number of files
    // that can be transpiled without error.
    assertTrue(countFilesCompiledToES(proot) <= 19);
}
Also used : N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 24 with N4jscBase

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

the class N4jscBasicTest method testMainHelp.

/**
 * Test successful exit, Exception is expected but with Error-Code 0
 */
@Test
public void testMainHelp() throws ExitCodeException {
    String[] args = { "--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 25 with N4jscBase

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

the class N4jscBasicTest method testMainInvalidDataAfterHelp.

/**
 * Test debug output before help. This test doesn't run a compile because of the "-help" option should end
 * execution.
 */
@Test
public void testMainInvalidDataAfterHelp() throws ExitCodeException {
    String[] args = { "--help", "--preferences", "xxx", "--buildType", "allprojects", "more1", "more2", "more3" };
    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)

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