use of org.eclipse.n4js.cli.helper.ProcessResult in project n4js by eclipse.
the class InstallCompileRunN4jscExternalShadowNestedNodeModulesTest method testCompileAndRunWithExternalDependencies.
/**
* Test for checking the npm support in the headless case by downloading third party package, importing it and
* running it with Common JS.
*
* TODO: use System.lineSeparator()
*/
@Test
public void testCompileAndRunWithExternalDependencies() {
final Path wsRoot = workspace.getAbsoluteFile().toPath();
final Path project = wsRoot.resolve("packages").resolve("P");
final Path fileToRun = project.resolve("src-gen").resolve("Main.js");
N4jscOptions options = COMPILE(workspace);
CliCompileResult cliResult = n4jsc(options, VALIDATION_ERRORS);
assertEquals(cliResult.toString(), 1, cliResult.getTranspiledFilesCount());
String expectedString = "Main.n4js in P\n";
expectedString += "#methodOld() in version 2.0.0\n";
expectedString += "#methodNew() in version 2.0.0";
ProcessResult nodejsResult = nodejsRun(workspace.toPath(), fileToRun);
assertEquals(nodejsResult.toString(), expectedString, nodejsResult.getStdOut());
}
use of org.eclipse.n4js.cli.helper.ProcessResult in project n4js by eclipse.
the class N4jscInitTest method yarnHelloWorldTested.
/**
* test yarn hello world test
*/
@Test
public void yarnHelloWorldTested() throws Exception {
N4jscTestOptions options = INIT().setWorkingDirectory(cwd.toPath()).workspaces().answers(",,,,,,yes,yes");
n4jsc(options, SUCCESS);
yarnInstall(cwd.toPath());
ProcessResult resultBuild = yarnRun(cwd.toPath(), "run", "build");
assertTrue(resultBuild.getStdOut().contains("Errors: 0"));
assertTrue(resultBuild.getStdOut().contains("Generated: 4"));
ProcessResult resultNodejs = nodejsRun(cwd.toPath(), Path.of("packages/my-project"));
assertEquals("Hello World", resultNodejs.getStdOut());
ProcessResult resultTest = yarnRun(cwd.toPath(), "run", "test");
assertTrue(resultTest.getStdOut().contains("Testing completed: [32mSUCCESSES[39m: 1, [31mFAILURES[39m: 0, [31mERRORS[39m: 0, [36mSKIPPED[39m: 0"));
}
use of org.eclipse.n4js.cli.helper.ProcessResult in project n4js by eclipse.
the class N4jscInitTest method helloWorld.
/**
* test hello world example
*/
@Test
public void helloWorld() throws Exception {
String answers = ",,,,,,yes";
N4jscTestOptions options = INIT().setWorkingDirectory(cwd.toPath()).answers(answers);
n4jsc(options, SUCCESS);
npmInstall(cwd.toPath());
CliCompileResult result = n4jsc(IMPLICIT_COMPILE(cwd).setWorkingDirectory(cwd.toPath()), SUCCESS);
assertEquals(1, result.getTranspiledFilesCount());
ProcessResult resultNodejs = nodejsRun(cwd.toPath(), Path.of("."));
assertEquals("Hello World", resultNodejs.getStdOut());
}
use of org.eclipse.n4js.cli.helper.ProcessResult in project n4js by eclipse.
the class IncompleteApiImplementationJarTest method testApiImplStub_CompileAndRunWithNodejsPlugin.
/**
* Compile & Run Tests for IDE-1510
*
* @throws Exception
* in Error cases
*/
@Test
@Ignore("GH-1291")
public void testApiImplStub_CompileAndRunWithNodejsPlugin() throws Exception {
Path workspace = Path.of(TARGET, WORKSPACE_FOLDER).toAbsolutePath();
Path nodeModulesPath = Paths.get(workspace.toString(), N4JSGlobals.NODE_MODULES).toAbsolutePath();
Path project = Path.of(workspace.toString(), N4CliHelper.PACKAGES, "one.x.impl").toAbsolutePath();
N4CliHelper.copyN4jsLibsToLocation(nodeModulesPath, N4JSGlobals.N4JS_RUNTIME);
CliCompileResult cliResult = n4jsc(COMPILE(project.toFile()));
assertEquals(cliResult.toString(), 2, cliResult.getTranspiledFilesCount());
Path fileA = project.resolve("src-gen/AT_IDE-1510_Missing_Method.js");
ProcessResult nodejsResult = nodejsRun(workspace, fileA);
assertTrue(nodejsResult.toString(), nodejsResult.getStdOut().contains("Hello from Implementation one.x.impl::p.A.n4js !"));
assertTrue(nodejsResult.toString(), nodejsResult.getStdOut().contains("N4ApiNotImplementedError: API for method A.missing_n not implemented yet."));
assertTrue(nodejsResult.toString(), nodejsResult.getStdOut().contains("N4ApiNotImplementedError: API for method A.missing_someIA not implemented yet."));
}
Aggregations