use of org.eclipse.n4js.tester.extension.ITesterDescriptor in project n4js by eclipse.
the class TesterFrontEnd method createConfiguration.
/**
* Similar to {@link RunnerFrontEnd#createConfiguration(String, String, URI)}, but for testing.
*
* @param testerId
* ID of the tester to use.
* @param implementationId
* implementation ID to use or <code>null</code>. See {@link RunConfiguration#getImplementationId() here}
* for details.
* @param moduleToTest
* URI referencing a resource to test. Can be an N4JS project, or a folder or file within an N4JS project
* for which {@link #canTest(URI)} returns true.
* @return the new run configuration.
*/
public TestConfiguration createConfiguration(String testerId, String implementationId, final URI moduleToTest) {
final ITesterDescriptor testerDesc = testerRegistry.getDescriptor(testerId);
final ITester tester = testerDesc.getTester();
final TestConfiguration config = tester.createConfiguration();
config.setName(computeConfigurationName(testerId, moduleToTest));
config.setTesterId(testerId);
config.setRunnerId(tester.getRunnerIdForTesting());
config.setRuntimeEnvironment(testerDesc.getEnvironment());
config.setImplementationId(implementationId);
config.setUserSelection(moduleToTest);
computeDerivedValues(config);
return config;
}
use of org.eclipse.n4js.tester.extension.ITesterDescriptor in project n4js by eclipse.
the class HeadlessTester method runTests.
/**
* Actually start the requested tester to test provided location. Workspace from headlesCompiler should be
* configured before calling this method.
*
* @param tester
* the tester to be used
* @param implementationId
* to be used for API-IMPL projects
* @param locationToTest
* location of the test code
* @throws ExitCodeException
* in cases of errors
*/
public void runTests(String tester, String implementationId, URI locationToTest, File testReportRoot) throws ExitCodeException {
ITesterDescriptor testerDescriptor = checkTester(tester);
logger.info("Using tester :" + testerDescriptor.getId());
TestConfiguration testConfiguration = null;
try {
testConfiguration = testerFrontEnd.createConfiguration(testerDescriptor.getId(), implementationId, locationToTest);
} catch (java.lang.IllegalStateException e2) {
logger.error(Throwables.getStackTraceAsString(e2));
throw new ExitCodeException(EXITCODE_TESTER_STOPPED_WITH_ERROR, "Cannot create test configuration.", e2);
}
try {
TestTree testTree = testConfiguration.getTestTree();
LoggingTestListener testListener = new LoggingTestListener(testerEventBus, logger, testTree);
Process process = testerFrontEnd.test(testConfiguration);
int exit = process.waitFor();
if (!testListener.finished())
throw new ExitCodeException(EXITCODE_TESTER_STOPPED_WITH_ERROR, "Test session has not finished.");
if (testReportRoot != null)
createTestReport(testReportRoot, testTree);
if (!testListener.isOK())
throw new ExitCodeException(EXITCODE_TESTER_STOPPED_WITH_ERROR, "There were test errors, see console logs and/or test report for details.");
if (exit != 0)
throw new ExitCodeException(EXITCODE_TESTER_STOPPED_WITH_ERROR, "The spawned tester '" + testerDescriptor.getId() + "' exited with code=" + exit);
} catch (InterruptedException e1) {
logger.error(Throwables.getStackTraceAsString(e1));
throw new ExitCodeException(EXITCODE_TESTER_STOPPED_WITH_ERROR, "The spawned tester exited by throwing an exception", e1);
} finally {
testerFacade.shutdownFramework();
}
}
Aggregations