Search in sources :

Example 1 with ITesterDescriptor

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;
}
Also used : ITesterDescriptor(org.eclipse.n4js.tester.extension.ITesterDescriptor)

Example 2 with ITesterDescriptor

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();
    }
}
Also used : ITesterDescriptor(org.eclipse.n4js.tester.extension.ITesterDescriptor) TestConfiguration(org.eclipse.n4js.tester.TestConfiguration) ExitCodeException(org.eclipse.n4js.hlc.base.ExitCodeException) TestTree(org.eclipse.n4js.tester.domain.TestTree)

Aggregations

ITesterDescriptor (org.eclipse.n4js.tester.extension.ITesterDescriptor)2 ExitCodeException (org.eclipse.n4js.hlc.base.ExitCodeException)1 TestConfiguration (org.eclipse.n4js.tester.TestConfiguration)1 TestTree (org.eclipse.n4js.tester.domain.TestTree)1