use of org.eclipse.n4js.cli.N4jscTestOptions in project n4js by eclipse.
the class N4jscBasicTest method testBuildDependentFilesIfFileReadded.
/**
* Test a second run of the compiler after a file was added to fix compile problems
*/
@Test
public void testBuildDependentFilesIfFileReadded() throws Exception {
N4jscTestOptions compileOptions = COMPILE(DONT_CLEAN, workspace);
CliCompileResult firstRun = n4jsc(compileOptions, SUCCESS);
assertEquals(firstRun.toString(), 20, firstRun.getTranspiledFilesCount());
Path fileCn4js = proot.toPath().resolve("P1/src/c/C.n4js");
byte[] bytesC = Files.readAllBytes(fileCn4js);
Files.delete(fileCn4js);
n4jsc(compileOptions, VALIDATION_ERRORS);
// Y.n4js depends on C.n4js
File fileCjs = proot.toPath().resolve("P1/src-gen/c/C.js").toFile();
assertFalse(fileCjs.exists());
File fileYjs = proot.toPath().resolve("P1/src-gen/y/Y.js").toFile();
assertFalse(fileYjs.exists());
Files.write(fileCn4js, bytesC);
CliCompileResult thirdRun = n4jsc(compileOptions, SUCCESS);
assertTrue(fileCjs.exists());
assertTrue(fileYjs.exists());
assertOutputEqual(firstRun, thirdRun);
}
use of org.eclipse.n4js.cli.N4jscTestOptions in project n4js by eclipse.
the class N4jscBasicTest method testFileRegeneratedIfMapRemoved.
/**
* Test a second run of the compiler after a generated js file was removed
*/
@Test
public void testFileRegeneratedIfMapRemoved() throws Exception {
N4jscTestOptions compileOptions = COMPILE(DONT_CLEAN, workspace);
CliCompileResult firstRun = n4jsc(compileOptions, SUCCESS);
assertEquals(firstRun.toString(), 20, firstRun.getTranspiledFilesCount());
File fileAmap = proot.toPath().resolve("P1/src-gen/A.map").toFile();
assertTrue(fileAmap.getAbsolutePath(), fileAmap.isFile());
assertTrue(fileAmap.getAbsolutePath(), fileAmap.exists());
assertTrue(fileAmap.getAbsolutePath(), fileAmap.delete());
assertFalse(fileAmap.getAbsolutePath(), fileAmap.exists());
CliCompileResult secondRun = n4jsc(compileOptions, SUCCESS);
assertEquals(secondRun.toString(), 1, secondRun.getTranspiledFilesCount());
assertEquals(secondRun.toString(), 0, secondRun.getDeletedFilesCount());
assertTrue(fileAmap.exists());
File fileAjs = proot.toPath().resolve("P1/src-gen/A.js").toFile();
assertTrue(fileAjs.exists());
assertOutputEqual(firstRun, secondRun);
}
use of org.eclipse.n4js.cli.N4jscTestOptions in project n4js by eclipse.
the class N4jscBasicTest method testBuildDependentFilesIfFileRemoved.
/**
* Test a second run of the compiler after a file with downstream files was removed
*/
@Test
public void testBuildDependentFilesIfFileRemoved() throws Exception {
N4jscTestOptions compileOptions = COMPILE(DONT_CLEAN, workspace);
CliCompileResult firstRun = n4jsc(compileOptions, SUCCESS);
assertEquals(firstRun.toString(), 20, firstRun.getTranspiledFilesCount());
File fileCn4js = proot.toPath().resolve("P1/src/c/C.n4js").toFile();
assertTrue(fileCn4js.getAbsolutePath(), fileCn4js.isFile());
assertTrue(fileCn4js.getAbsolutePath(), fileCn4js.exists());
assertTrue(fileCn4js.getAbsolutePath(), fileCn4js.delete());
assertFalse(fileCn4js.getAbsolutePath(), fileCn4js.exists());
CliCompileResult secondRun = n4jsc(compileOptions, VALIDATION_ERRORS);
// Z and Z3 are affected indirectly
assertEquals(secondRun.toString(), 2, secondRun.getTranspiledFilesCount());
// C and Y are affected (js and map)
assertEquals(secondRun.toString(), 4, secondRun.getDeletedFilesCount());
// Y.n4js depends on C.n4js
File fileYjs = proot.toPath().resolve("P1/src-gen/y/Y.js").toFile();
assertFalse(fileYjs.exists());
}
use of org.eclipse.n4js.cli.N4jscTestOptions in project n4js by eclipse.
the class N4jscBasicTest method testRunTwice.
/**
* Test a second run of the compiler on the same sources
*/
@Test
public void testRunTwice() throws Exception {
N4jscTestOptions compileOptions = COMPILE(DONT_CLEAN, workspace);
CliCompileResult firstRun = n4jsc(compileOptions, SUCCESS);
assertEquals(firstRun.toString(), 20, firstRun.getTranspiledFilesCount());
Path fileA = proot.toPath().resolve("P1/.n4js.projectstate");
assertTrue(fileA.toFile().getAbsolutePath(), fileA.toFile().exists());
CliCompileResult secondRun = n4jsc(compileOptions, SUCCESS);
assertEquals(secondRun.toString(), 0, secondRun.getTranspiledFilesCount());
assertOutputEqual(firstRun, secondRun);
}
use of org.eclipse.n4js.cli.N4jscTestOptions in project n4js by eclipse.
the class N4jscBasicTest method testFileRemovedIfN4JSRemoved.
/**
* Test a second run of the compiler after a source file was removed
*/
@Test
public void testFileRemovedIfN4JSRemoved() throws Exception {
N4jscTestOptions compileOptions = COMPILE(DONT_CLEAN, workspace);
CliCompileResult firstRun = n4jsc(compileOptions, SUCCESS);
assertEquals(firstRun.toString(), 20, firstRun.getTranspiledFilesCount());
File fileAn4js = proot.toPath().resolve("P1/src/A.n4js").toFile();
assertTrue(fileAn4js.getAbsolutePath(), fileAn4js.isFile());
assertTrue(fileAn4js.getAbsolutePath(), fileAn4js.exists());
assertTrue(fileAn4js.getAbsolutePath(), fileAn4js.delete());
assertFalse(fileAn4js.getAbsolutePath(), fileAn4js.exists());
File fileAjs = proot.toPath().resolve("P1/src-gen/A.js").toFile();
assertTrue(fileAjs.exists());
File fileAmap = proot.toPath().resolve("P1/src-gen/A.map").toFile();
assertTrue(fileAmap.exists());
CliCompileResult secondRun = n4jsc(compileOptions, SUCCESS);
assertEquals(secondRun.toString(), 0, secondRun.getTranspiledFilesCount());
assertEquals(secondRun.toString(), 2, secondRun.getDeletedFilesCount());
assertFalse(fileAjs.exists());
assertFalse(fileAmap.exists());
}
Aggregations