use of org.eclipse.n4js.cli.helper.CliCompileResult in project n4js by eclipse.
the class N4jscInitTest method yarnHelloWorld.
/**
* test yarn hello world
*/
@Test
public void yarnHelloWorld() throws Exception {
N4jscTestOptions options = INIT().setWorkingDirectory(cwd.toPath()).workspaces().answers(",,,,,,yes");
n4jsc(options, SUCCESS);
yarnInstall(cwd.toPath());
CliCompileResult result = n4jsc(IMPLICIT_COMPILE(cwd).setWorkingDirectory(cwd.toPath()), SUCCESS);
assertEquals(1, result.getTranspiledFilesCount());
ProcessResult resultNodejs = nodejsRun(cwd.toPath(), Path.of("packages/my-project"));
assertEquals("Hello World", resultNodejs.getStdOut());
}
use of org.eclipse.n4js.cli.helper.CliCompileResult in project n4js by eclipse.
the class N4jscInitTest method failDueToExistingPackagejson.
/**
* fail due to existing package.json file
*/
@Test
public void failDueToExistingPackagejson() throws Exception {
File packjson = new File(cwd.getAbsoluteFile(), PACKAGE_JSON);
packjson.createNewFile();
N4jscTestOptions options = INIT().setWorkingDirectory(cwd.toPath()).yes();
CliCompileResult result = n4jsc(options, INIT_ERROR_WORKING_DIR);
assertEquals("ERROR-410 (Error: Unsupported working directory): Current working directory must not contain a package.json file. Note:\n" + " In case you like to add the n4js property to an existing project, use option --n4js.\n" + " In case you like to add a project to an existing workspace project, use options -w -c.", result.getStdOut());
}
use of org.eclipse.n4js.cli.helper.CliCompileResult in project n4js by eclipse.
the class N4jscInitTest method yarnWrongLocation1ScopeCreate.
/**
* test yarn at wrong location
*/
@Test
public void yarnWrongLocation1ScopeCreate() throws Exception {
// create environment
N4jscTestOptions options = INIT().setWorkingDirectory(cwd.toPath()).yes().workspaces();
n4jsc(options, SUCCESS);
assertEquals("TestInit\n" + "- package.json\n" + "+ packages\n" + " + my-project\n" + " - package.json\n" + " + src\n" + " + src-gen\n" + "", FileUtils.serializeFileTree(cwd));
// test
File newProject = new File(cwd, "packages");
options = INIT().yes().setWorkingDirectory(newProject.toPath()).scope().create();
CliCompileResult result = n4jsc(options, INIT_ERROR_WORKING_DIR);
assertEquals("ERROR-410 (Error: Unsupported working directory): " + "Creating a new project inside an existing yarn project requires option '--workspaces' to be set.", result.getStdOut());
}
use of org.eclipse.n4js.cli.helper.CliCompileResult in project n4js by eclipse.
the class N4jscInitTest method mainModule1Compile.
/**
* test for a custom main module
*/
@Test
public void mainModule1Compile() throws Exception {
String answers = ",,index.js";
N4jscTestOptions options = INIT().setWorkingDirectory(cwd.toPath()).answers(answers);
n4jsc(options, SUCCESS);
String packagejsonContents = Files.readString(cwd.toPath().resolve(PACKAGE_JSON));
assertEquals("{\n" + " \"name\": \"TestInit\",\n" + " \"version\": \"0.0.1\",\n" + " \"type\": \"module\",\n" + " \"main\": \"src-gen/index.js\",\n" + " \"scripts\": {\n" + " \"n4jsc\": \"n4jsc\",\n" + " \"build\": \"n4jsc compile . --clean || true\"\n" + " },\n" + " \"dependencies\": {\n" + " \"n4js-runtime\": \"\",\n" + " \"n4js-runtime-es2015\": \"\"\n" + " },\n" + " \"devDependencies\": {\n" + " \"n4js-cli\": \"\"\n" + " },\n" + " \"n4js\": {\n" + " \"projectType\": \"library\",\n" + " \"mainModule\": \"index\",\n" + " \"output\": \"src-gen\",\n" + " \"sources\": {\n" + " \"source\": [\n" + " \"src\"\n" + " ]\n" + " },\n" + " \"requiredRuntimeLibraries\": [\n" + " \"n4js-runtime-es2015\"\n" + " ]\n" + " }\n" + "}", packagejsonContents);
assertEquals("TestInit\n" + "- package.json\n" + "+ src\n" + " - index.n4js\n" + "+ src-gen\n" + "", FileUtils.serializeFileTree(cwd));
npmInstall(cwd.toPath());
CliCompileResult result = n4jsc(IMPLICIT_COMPILE(cwd).setWorkingDirectory(cwd.toPath()), SUCCESS);
assertEquals(1, result.getTranspiledFilesCount());
}
use of org.eclipse.n4js.cli.helper.CliCompileResult in project n4js by eclipse.
the class FrontendCompileTest method checkNoTestsWrongGoal.
/**
*/
@Test
public void checkNoTestsWrongGoal() {
String[] args = { "lsp", ".", "--noTests" };
CliCompileResult result = n4jsc(args, 10);
assertEquals(result.toString(), "ERROR-10 (Invalid command line string): No argument is allowed: .", result.getStdOut());
}
Aggregations