Search in sources :

Example 1 with N4jscBase

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

the class N4jscArgumentOrderTest method testDifferentArgumentOrder.

/**
 * normal compile all test without flag "--keepCompiling"
 */
@Test
public void testDifferentArgumentOrder() {
    String[] shuffledArgs = shuffleArgs(shuffleOrder);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    PrintStream old = System.out;
    System.setOut(ps);
    try {
        new N4jscBase().doMain(shuffledArgs);
        Reader reader = new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()));
        BufferedReader bufferedReader = new BufferedReader(reader);
        String line = null;
        String actualOrder = "";
        while ((line = bufferedReader.readLine()) != null) {
            if (line.contains(". Project ")) {
                old.println(line);
                actualOrder += line + "\n";
            }
        }
        assertEquals(expectedOrder, actualOrder);
    } catch (Exception e) {
        e.printStackTrace(System.err);
        fail();
    } finally {
        System.out.flush();
        System.setOut(old);
    }
}
Also used : PrintStream(java.io.PrintStream) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedReader(java.io.BufferedReader) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) ByteArrayOutputStream(java.io.ByteArrayOutputStream) N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) IOException(java.io.IOException) Test(org.junit.Test)

Example 2 with N4jscBase

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

the class N4jscBasicTest method testCleanAllProjects.

/**
 * Test that clean removes files in src-gen folder but does not compile when compiling all projects in a given root.
 */
@Test
public void testCleanAllProjects() throws ExitCodeException {
    String proot = workspace.getAbsolutePath().toString();
    String[] args = { "--clean", "--projectlocations", proot, "--buildType", "allprojects" };
    new N4jscBase().doMain(args);
    // 0 = 0 in all projects inside wsp/basic
    assertEquals(0, countFilesCompiledToES(proot));
}
Also used : N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 3 with N4jscBase

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

the class N4jscBasicTest method testNoCleanSingleProject.

/**
 * Test that clean build is not triggered when --clean/-c is not used.
 *
 * @throws ExitCodeException
 *             expected
 */
@Test
public void testNoCleanSingleProject() throws ExitCodeException {
    String proot = workspace.getAbsolutePath().toString();
    String project = "TestCleanPrj1";
    String pathToProject = proot + "/" + project;
    String[] args = { "--projectlocations", proot, "--buildType", "projects", pathToProject };
    new N4jscBase().doMain(args);
    // 4 = 3 in TestCleanPrj1 + 1 in TestCleanPrj2
    assertEquals(4, countFilesCompiledToES(proot));
}
Also used : N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 4 with N4jscBase

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

the class N4jscBasicTest method testMainHelpDebug.

/**
 * Test debug output after help.
 */
@Test
public void testMainHelpDebug() throws ExitCodeException {
    String[] args = { "--help", "--debug" };
    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 5 with N4jscBase

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

the class N4jscBasicTest method testMainArgsProjectRoot.

/**
 * normal compile test
 */
@Test
public void testMainArgsProjectRoot() throws ExitCodeException {
    String proot = workspace.getAbsolutePath().toString();
    // absolute filename
    String file1 = proot + "/" + "PSingle/src/a/A.n4js";
    String[] args = { "--projectlocations", proot, file1 };
    new N4jscBase().doMain(args);
}
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