Search in sources :

Example 16 with CliCompileResult

use of org.eclipse.n4js.cli.helper.CliCompileResult in project n4js by eclipse.

the class N4jscInitTest method yarnWrongLocation2.

/**
 * test yarn at wrong location
 */
@Test
public void yarnWrongLocation2() 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
    options = INIT().yes().setWorkingDirectory(cwd.toPath()).workspaces();
    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());
}
Also used : CliCompileResult(org.eclipse.n4js.cli.helper.CliCompileResult) N4jscTestOptions(org.eclipse.n4js.cli.N4jscTestOptions) Test(org.junit.Test) AbstractCliCompileTest(org.eclipse.n4js.cli.helper.AbstractCliCompileTest)

Example 17 with CliCompileResult

use of org.eclipse.n4js.cli.helper.CliCompileResult in project n4js by eclipse.

the class N4jscInitTest method yarnWrongLocation3.

/**
 * test yarn at wrong location
 */
@Test
public void yarnWrongLocation3() 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
    options = INIT().yes().setWorkingDirectory(cwd.toPath().resolve("packages")).workspaces().scope();
    CliCompileResult result = n4jsc(options, INIT_ERROR_WORKING_DIR);
    assertEquals("ERROR-410 (Error: Unsupported working directory):  When creating a scoped package the parent directory of current working directory must start with '@'. Note:\n" + "  In case you like to create a new project in a subfolder of the current working directory, use option -c.", result.getStdOut());
}
Also used : CliCompileResult(org.eclipse.n4js.cli.helper.CliCompileResult) N4jscTestOptions(org.eclipse.n4js.cli.N4jscTestOptions) Test(org.junit.Test) AbstractCliCompileTest(org.eclipse.n4js.cli.helper.AbstractCliCompileTest)

Example 18 with CliCompileResult

use of org.eclipse.n4js.cli.helper.CliCompileResult in project n4js by eclipse.

the class N4jscInitTest method yarnWrongLocation1Scope.

/**
 * test yarn at wrong location
 */
@Test
public void yarnWrongLocation1Scope() 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();
    CliCompileResult result = n4jsc(options, INIT_ERROR_WORKING_DIR);
    assertEquals("ERROR-410 (Error: Unsupported working directory):  When creating a scoped package the parent directory of current working directory must start with '@'. Note:\n" + "  In case you like to create a new project in a subfolder of the current working directory, use option -c.", result.getStdOut());
}
Also used : CliCompileResult(org.eclipse.n4js.cli.helper.CliCompileResult) N4jscTestOptions(org.eclipse.n4js.cli.N4jscTestOptions) File(java.io.File) Test(org.junit.Test) AbstractCliCompileTest(org.eclipse.n4js.cli.helper.AbstractCliCompileTest)

Example 19 with CliCompileResult

use of org.eclipse.n4js.cli.helper.CliCompileResult in project n4js by eclipse.

the class N4jscInitTest method otherName.

/**
 * test another project name
 */
@Test
public void otherName() throws Exception {
    String answers = "otherName";
    N4jscTestOptions options = INIT().setWorkingDirectory(cwd.toPath()).answers(answers);
    CliCompileResult result = n4jsc(options, SUCCESS);
    npmInstall(cwd.toPath());
    result = n4jsc(IMPLICIT_COMPILE(cwd).setWorkingDirectory(cwd.toPath()), SUCCESS);
    // there are no files to transpile
    assertEquals(0, result.getTranspiledFilesCount());
    String packagejsonContents = Files.readString(cwd.toPath().resolve(PACKAGE_JSON));
    assertTrue(packagejsonContents.contains("  \"name\": \"otherName\",\n"));
}
Also used : CliCompileResult(org.eclipse.n4js.cli.helper.CliCompileResult) N4jscTestOptions(org.eclipse.n4js.cli.N4jscTestOptions) Test(org.junit.Test) AbstractCliCompileTest(org.eclipse.n4js.cli.helper.AbstractCliCompileTest)

Example 20 with CliCompileResult

use of org.eclipse.n4js.cli.helper.CliCompileResult in project n4js by eclipse.

the class N4jscInitTest method optionsErrorYesScope.

/**
 * --scope test.
 */
@Test
public void optionsErrorYesScope() throws Exception {
    File subfolder = new File(cwd, "nonScopeFolder/scopedProject");
    subfolder.mkdir();
    N4jscTestOptions options = INIT().setWorkingDirectory(subfolder.toPath()).yes().scope();
    CliCompileResult result = n4jsc(options, INIT_ERROR_WORKING_DIR);
    assertEquals("ERROR-410 (Error: Unsupported working directory):  When creating a scoped package the parent directory of current working directory must start with '@'. Note:\n" + "  In case you like to create a new project in a subfolder of the current working directory, use option -c.", result.getStdOut());
}
Also used : CliCompileResult(org.eclipse.n4js.cli.helper.CliCompileResult) N4jscTestOptions(org.eclipse.n4js.cli.N4jscTestOptions) File(java.io.File) Test(org.junit.Test) AbstractCliCompileTest(org.eclipse.n4js.cli.helper.AbstractCliCompileTest)

Aggregations

CliCompileResult (org.eclipse.n4js.cli.helper.CliCompileResult)92 Test (org.junit.Test)90 AbstractCliCompileTest (org.eclipse.n4js.cli.helper.AbstractCliCompileTest)41 N4jscTestOptions (org.eclipse.n4js.cli.N4jscTestOptions)22 File (java.io.File)20 Path (java.nio.file.Path)12 ProcessResult (org.eclipse.n4js.cli.helper.ProcessResult)12 N4jscOptions (org.eclipse.n4js.cli.N4jscOptions)8 AbstractCliJarTest (org.eclipse.n4js.cli.helper.AbstractCliJarTest)6 Gson (com.google.gson.Gson)1 JsonObject (com.google.gson.JsonObject)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 CliTools (org.eclipse.n4js.cli.helper.CliTools)1 CliException (org.eclipse.n4js.cli.helper.CliTools.CliException)1 Ignore (org.junit.Ignore)1