Search in sources :

Example 31 with N4jscBase

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

the class N4JSXTest method testOnlyN4JSX.

/**
 * Compile a single n4jsx file without any n4js files in the workspace.
 */
@Test
public void testOnlyN4JSX() throws ExitCodeException {
    final String wsRoot = workspace.getAbsolutePath().toString();
    String react = wsRoot + "/react";
    String p1Root = wsRoot + "/" + "P1";
    new N4jscBase().doMain("--projectlocations", wsRoot, "--buildType", "projects", p1Root, react);
    assertFilesCompiledToES(1, p1Root);
}
Also used : N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 32 with N4jscBase

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

the class N4JSXTest method testCombinedWithN4JS_singleFile.

/**
 * Same as {@link #testCombinedWithN4JS()}, but the files are compiled individually using 'singlefile' mode.
 */
@Test
public void testCombinedWithN4JS_singleFile() throws ExitCodeException {
    final String wsRoot = workspace.getAbsolutePath().toString();
    String p2Root = wsRoot + "/" + "P2";
    new N4jscBase().doMain("--projectlocations", wsRoot, "--buildType", "singlefile", p2Root + "/src/foo.n4js");
    assertFilesCompiledToES(1, p2Root);
    new N4jscBase().doMain("--projectlocations", wsRoot, "--buildType", "singlefile", p2Root + "/src/bar.n4jsx");
    assertFilesCompiledToES(2, p2Root);
    new N4jscBase().doMain("--projectlocations", wsRoot, "--buildType", "singlefile", p2Root + "/src/bar2.n4jsx");
    assertFilesCompiledToES(3, p2Root);
}
Also used : N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 33 with N4jscBase

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

the class AT_IDEBUG_532_transpilecrashTest method testCompileOfExtendedIterator_from_RuntimeLibrary.

/**
 * The Problem was, that nothing was compiled.
 */
@Test
public void testCompileOfExtendedIterator_from_RuntimeLibrary() throws ExitCodeException {
    String proot = workspace.getAbsolutePath().toString();
    String[] args = { "--projectlocations", proot, "--buildType", "allprojects", "--verbose" };
    // compile
    new N4jscBase().doMain(args);
    // Make sure, we get here and have exactly one file compiled:
    assertFilesCompiledToES(1, proot);
}
Also used : N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Test(org.junit.Test)

Example 34 with N4jscBase

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

the class UpdateShippedCode method cleanAndcompile.

private static void cleanAndcompile(File... foldersContainingProjectFolders) {
    final String foldersContainingProjectsStr = Stream.of(foldersContainingProjectFolders).map(file -> file.getAbsolutePath()).collect(Collectors.joining(File.pathSeparator));
    // Clean all projects first
    final String[] cleanArgs = { "--clean", "--buildType", "allprojects", "--projectlocations", foldersContainingProjectsStr };
    try {
        new N4jscBase().doMain(cleanArgs);
    } catch (ExitCodeException e) {
        println("ERROR: while cleaning the projects, an ExitCodeException is thrown; " + "code: " + e.getExitCode() + ", " + "message: " + e.getMessage());
        e.printStackTrace();
        throw new RuntimeException(e);
    }
    // Then compile the projects
    final String[] args = { "--buildType", "allprojects", "--projectlocations", foldersContainingProjectsStr };
    try {
        new N4jscBase().doMain(args);
    } catch (ExitCodeException e) {
        println("ERROR: headless compiler threw ExitCodeException (probably code compiled with errors); " + "code: " + e.getExitCode() + ", " + "message: " + e.getMessage());
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}
Also used : UtilN4(org.eclipse.n4js.utils.UtilN4) NodeBinaryLocatorHelper(org.eclipse.n4js.binaries.nodejs.NodeBinaryLocatorHelper) FileDeleter(org.eclipse.n4js.utils.io.FileDeleter) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) N4JSGlobals(org.eclipse.n4js.N4JSGlobals) Optional(com.google.common.base.Optional) IWorkflowComponent(org.eclipse.emf.mwe2.runtime.workflow.IWorkflowComponent) JsonNode(com.fasterxml.jackson.databind.JsonNode) LinkedList(java.util.LinkedList) N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase) Path(java.nio.file.Path) ExternalLibrariesActivator(org.eclipse.n4js.external.libraries.ExternalLibrariesActivator) NodeProcessBuilder(org.eclipse.n4js.binaries.nodejs.NodeProcessBuilder) N4JSStandaloneSetup(org.eclipse.n4js.N4JSStandaloneSetup) FileVisitor(java.nio.file.FileVisitor) Iterator(java.util.Iterator) Files(java.nio.file.Files) FileCopier(org.eclipse.n4js.utils.io.FileCopier) IWorkflowContext(org.eclipse.emf.mwe2.runtime.workflow.IWorkflowContext) FileWriter(java.io.FileWriter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes) Collectors(java.util.stream.Collectors) File(java.io.File) Injector(com.google.inject.Injector) FileVisitResult(java.nio.file.FileVisitResult) List(java.util.List) Stream(java.util.stream.Stream) Entry(java.util.Map.Entry) ExitCodeException(org.eclipse.n4js.hlc.base.ExitCodeException) ExitCodeException(org.eclipse.n4js.hlc.base.ExitCodeException) N4jscBase(org.eclipse.n4js.hlc.base.N4jscBase)

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