use of org.eclipse.n4js.generator.headless.N4HeadlessCompiler in project n4js by eclipse.
the class AccessControlTest method compile.
/**
* Compiles the projects generated into the path at {@link #FIXTURE_ROOT}, which in this test case the projects
* representing the currently tested scenario and returns the generated issues.
*
* @return the generated issues
*/
private static Collection<Issue> compile(MemberType memberType) {
IssueCollector issueCollector = new IssueCollector();
try {
N4HeadlessCompiler hlc = HeadlessCompilerFactory.createCompilerWithDefaults();
final File projectRoot = Paths.get(FIXTURE_ROOT, memberType.name()).toFile();
hlc.compileAllProjects(Arrays.asList(projectRoot), issueCollector);
} catch (N4JSCompileException e) {
// nothing to do
}
return issueCollector.getCollectedIssues();
}
use of org.eclipse.n4js.generator.headless.N4HeadlessCompiler in project n4js by eclipse.
the class ScenarioTest method testScenario11FailDueToInvisbleProject.
/**
* Testing compiling
*/
@Test
public void testScenario11FailDueToInvisbleProject() {
N4HeadlessCompiler hlc = HeadlessCompilerFactory.createCompilerWithDefaults();
File root = new File(workspace, "scenario11");
List<File> pProjectRoots = //
Arrays.asList(new File(root, "wsp1"));
try {
hlc.compileAllProjects(pProjectRoots);
assertFalse("Should not have reached this point.", true);
} catch (N4JSCompileException e) {
String msg = e.getMessage();
String expected = "Cannot compile project D due to 4 errors.";
assertTrue("Wrong error message: '" + msg + "' expected beginning : '" + expected + "'", msg.startsWith(expected));
}
// expect source-files (depends on the chosen build order algorithm):
assertExists(root, "wsp1/A/src-gen/packA/A.js");
assertExists(root, "wsp1/C/src-gen/packC/C.js");
}
use of org.eclipse.n4js.generator.headless.N4HeadlessCompiler in project n4js by eclipse.
the class ScenarioTest method testScenario05BuildSingleProjectsWithoutProjectroot.
/**
*/
@Test
public void testScenario05BuildSingleProjectsWithoutProjectroot() throws N4JSCompileException {
N4HeadlessCompiler hlc = HeadlessCompilerFactory.createCompilerWithDefaults();
File root = new File(workspace, "scenario05");
List<File> toCompile = //
Arrays.asList(// requires B and A to be loaded.
new File(root, "nest/wsp2/D"), // requires nothing
new File(root, "nest/wsp2/B"), // requires nothing
new File(root, "wsp1/A"));
hlc.compileProjects(toCompile);
// those should be available
assertExists(root, "wsp1/A/src-gen/packA/A.js");
assertExists(root, "nest/wsp2/B/src-gen/packB/B.js");
assertExists(root, "nest/wsp2/D/src-gen/packD/D.js");
assertExists(root, "nest/wsp2/D/src-gen/packD/D2.js");
}
use of org.eclipse.n4js.generator.headless.N4HeadlessCompiler in project n4js by eclipse.
the class ScenarioTest method testScenario02brokenManifest.
/**
* Broken manifest will result in parse-error.
*/
@Test(expected = N4JSCompileException.class)
public void testScenario02brokenManifest() throws N4JSCompileException {
N4HeadlessCompiler hlc = HeadlessCompilerFactory.createCompilerWithDefaults();
File root = new File(workspace, "scenario02");
List<File> pProjectRoots = //
Arrays.asList(// A
new File(root, "wsp1"));
hlc.compileAllProjects(pProjectRoots);
}
use of org.eclipse.n4js.generator.headless.N4HeadlessCompiler in project n4js by eclipse.
the class ScenarioTest method testScenario07TestOnlyCompilation.
/**
* Building a project but only the test-files.
*/
@Test
public void testScenario07TestOnlyCompilation() throws N4JSCompileException {
N4HeadlessCompiler hlc = HeadlessCompilerFactory.createCompilerWithDefaults();
File root = new File(workspace, "scenario07");
List<File> toCompile = //
Arrays.asList(// requires nothing
new File(root, "wsp1/P1"));
hlc.setCompileSourceCode(false);
hlc.setProcessTestCode(true);
hlc.compileProjects(toCompile);
// those should be available
assertNotExists(root, "wsp1/P1/outfolder/c/Csrc1.js");
assertNotExists(root, "wsp1/P1/outfolder/c/X.js");
assertNotExists(root, "wsp1/P1/outfolder/c/X2.js");
assertExists(root, "wsp1/P1/outfolder/t/T1.js");
assertExists(root, "wsp1/P1/outfolder/t/T2.js");
// there should be no src-gen folder:
assertNotExists(root, "wsp1/P1/src-gen");
}
Aggregations