use of org.eclipse.n4js.generator.headless.N4JSCompileException 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.N4JSCompileException 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.N4JSCompileException in project n4js by eclipse.
the class N4jscBase method doCompileAndTestAndRun.
/**
* Core algorithm to call the invoke compilation testing and running.
*
* @throws ExitCodeException
* in error cases.
*/
private void doCompileAndTestAndRun() throws ExitCodeException {
if (debug) {
System.out.println("N4JS compiling...");
}
try {
switch(buildtype) {
case singlefile:
compileArgumentsAsSingleFiles();
break;
case projects:
compileArgumentsAsProjects();
break;
case allprojects:
compileAllProjects();
break;
case dontcompile:
default:
registerProjects();
}
} catch (N4JSCompileException e) {
// dump all information to error-stream.
e.userDump(System.err);
throw new ExitCodeException(EXITCODE_COMPILE_ERROR);
}
if (null != testCatalogFile) {
final String catalog = testCatalogSupplier.get();
try (final FileOutputStream fos = new FileOutputStream(testCatalogFile)) {
fos.write(catalog.getBytes());
fos.flush();
} catch (IOException e) {
System.out.println("Error while writing test catalog file at: " + testCatalogFile);
throw new ExitCodeException(EXITCODE_TEST_CATALOG_ASSEMBLATION_ERROR);
}
}
if (testThisLocation != null) {
if (buildtype != BuildType.dontcompile) {
flushAndIinsertMarkerInOutputs();
}
headlessTester.runTests(tester, implementationId, checkLocationToTest(), testReportRoot);
}
if (runThisFile != null) {
if (buildtype != BuildType.dontcompile) {
flushAndIinsertMarkerInOutputs();
}
headlessRunner.startRunner(runner, implementationId, systemLoader, checkFileToRun(), targetPlatformInstallLocation);
}
if (debug) {
System.out.println("... done.");
}
}
Aggregations