Search in sources :

Example 1 with TestConfiguration

use of org.eclipse.n4js.tester.TestConfiguration in project n4js by eclipse.

the class AbstractTesterLaunchShortcut method launchTest.

/**
 * Launch a test of the given URI (may point to project, folder, file).
 */
protected void launchTest(URI resourceToTest, String mode) {
    TestConfiguration testConfig = testerFrontEnd.createConfiguration(getTesterId(), null, resourceToTest);
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(getLaunchConfigTypeID());
    DebugUITools.launch(testConfigConverter.toLaunchConfiguration(type, testConfig), mode);
// execution dispatched to proper ILaunchConfigurationDelegate
}
Also used : ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) TestConfiguration(org.eclipse.n4js.tester.TestConfiguration) ILaunchManager(org.eclipse.debug.core.ILaunchManager)

Example 2 with TestConfiguration

use of org.eclipse.n4js.tester.TestConfiguration in project n4js by eclipse.

the class TestResultsView method performRelaunch.

/**
 * Invoked when user performs {@link #actionRelaunch}.
 */
protected void performRelaunch() {
    if (null != currentRoot) {
        final TestSession session = from(registeredSessions).firstMatch(s -> s.root == currentRoot).orNull();
        if (null != session) {
            final TestConfiguration configurationToReRun = session.configuration;
            registeredSessions.remove(session);
            try {
                final TestConfiguration newConfiguration = testerFrontEnd.createConfiguration(configurationToReRun);
                testerFrontEndUI.runInUI(newConfiguration);
            } catch (Exception e) {
                String message = "Test class not found in the workspace.";
                if (!Strings.isNullOrEmpty(e.getMessage())) {
                    message += " Reason: " + e.getMessage();
                }
                MessageDialog.openError(getShell(), "Cannot open editor", message);
            }
        }
    }
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) StyledText(org.eclipse.swt.custom.StyledText) IN4JSEclipseCore(org.eclipse.n4js.ui.projectModel.IN4JSEclipseCore) Point(org.eclipse.swt.graphics.Point) TestEndedEvent(org.eclipse.n4js.tester.events.TestEndedEvent) ERROR(org.eclipse.n4js.tester.domain.TestStatus.ERROR) Composite(org.eclipse.swt.widgets.Composite) PartInitException(org.eclipse.ui.PartInitException) IN4JSEclipseProject(org.eclipse.n4js.ui.projectModel.IN4JSEclipseProject) FluentIterable.from(com.google.common.collect.FluentIterable.from) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) Separator(org.eclipse.jface.action.Separator) Text(org.eclipse.swt.widgets.Text) SEPARATOR(org.eclipse.core.runtime.IPath.SEPARATOR) PlatformUI(org.eclipse.ui.PlatformUI) FAILED(org.eclipse.n4js.tester.domain.TestStatus.FAILED) MenuManager(org.eclipse.jface.action.MenuManager) TestCase(org.eclipse.n4js.tester.domain.TestCase) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) UIUtils.getShell(org.eclipse.n4js.ui.utils.UIUtils.getShell) SWT(org.eclipse.swt.SWT) SKIPPED_FIXME(org.eclipse.n4js.tester.domain.TestStatus.SKIPPED_FIXME) SessionFinishedEvent(org.eclipse.n4js.tester.events.SessionFinishedEvent) Joiner(com.google.common.base.Joiner) SKIPPED_NOT_IMPLEMENTED(org.eclipse.n4js.tester.domain.TestStatus.SKIPPED_NOT_IMPLEMENTED) ViewPart(org.eclipse.ui.part.ViewPart) URI(org.eclipse.emf.common.util.URI) TestEvent(org.eclipse.n4js.tester.events.TestEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TesterUiActivator(org.eclipse.n4js.tester.ui.TesterUiActivator) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) ControlListener(org.eclipse.swt.events.ControlListener) ArrayList(java.util.ArrayList) ControlEvent(org.eclipse.swt.events.ControlEvent) Strings(com.google.common.base.Strings) TestTree(org.eclipse.n4js.tester.domain.TestTree) Ints.asList(com.google.common.primitives.Ints.asList) IFile(org.eclipse.core.resources.IFile) GridData(org.eclipse.swt.layout.GridData) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) ID(org.eclipse.n4js.tester.domain.ID) PASSED(org.eclipse.n4js.tester.domain.TestStatus.PASSED) TesterFrontEnd(org.eclipse.n4js.tester.TesterFrontEnd) TestStatus(org.eclipse.n4js.tester.domain.TestStatus) IMemento(org.eclipse.ui.IMemento) IViewSite(org.eclipse.ui.IViewSite) IActionBars(org.eclipse.ui.IActionBars) Display.getDefault(org.eclipse.swt.widgets.Display.getDefault) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) SKIPPED_IGNORE(org.eclipse.n4js.tester.domain.TestStatus.SKIPPED_IGNORE) Color(org.eclipse.swt.graphics.Color) IMenuManager(org.eclipse.jface.action.IMenuManager) ToolTip(org.eclipse.jface.window.ToolTip) GridLayout(org.eclipse.swt.layout.GridLayout) Inject(com.google.inject.Inject) IAction(org.eclipse.jface.action.IAction) ToolBar(org.eclipse.swt.widgets.ToolBar) IToolBarManager(org.eclipse.jface.action.IToolBarManager) AllowConcurrentEvents(com.google.common.eventbus.AllowConcurrentEvents) IViewPart(org.eclipse.ui.IViewPart) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) MessageDialog.openError(org.eclipse.jface.dialogs.MessageDialog.openError) Display(org.eclipse.swt.widgets.Display) TestSuite(org.eclipse.n4js.tester.domain.TestSuite) Collectors(java.util.stream.Collectors) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) List(java.util.List) Tree(org.eclipse.swt.widgets.Tree) SessionFailedEvent(org.eclipse.n4js.tester.events.SessionFailedEvent) ITableColorProvider(org.eclipse.jface.viewers.ITableColorProvider) ISelection(org.eclipse.jface.viewers.ISelection) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Arrays.copyOfRange(java.util.Arrays.copyOfRange) TestConfiguration(org.eclipse.n4js.tester.TestConfiguration) TestElement(org.eclipse.n4js.tester.domain.TestElement) IMenuListener(org.eclipse.jface.action.IMenuListener) IURIEditorOpener(org.eclipse.xtext.ui.editor.IURIEditorOpener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) System.lineSeparator(java.lang.System.lineSeparator) NONE(org.eclipse.swt.SWT.NONE) SKIPPED(org.eclipse.n4js.tester.domain.TestStatus.SKIPPED) Image(org.eclipse.swt.graphics.Image) TestStartedEvent(org.eclipse.n4js.tester.events.TestStartedEvent) Event(org.eclipse.swt.widgets.Event) EditorContentExtractor(org.eclipse.n4js.ui.editor.EditorContentExtractor) TesterEventBus(org.eclipse.n4js.tester.TesterEventBus) TesterFrontEndUI(org.eclipse.n4js.tester.ui.TesterFrontEndUI) SKIPPED_PRECONDITION(org.eclipse.n4js.tester.domain.TestStatus.SKIPPED_PRECONDITION) Subscribe(com.google.common.eventbus.Subscribe) SessionStartedEvent(org.eclipse.n4js.tester.events.SessionStartedEvent) IWorkbenchActionConstants(org.eclipse.ui.IWorkbenchActionConstants) StyledTextDescriptor(org.eclipse.n4js.ui.editor.StyledTextDescriptor) SessionEndedEvent(org.eclipse.n4js.tester.events.SessionEndedEvent) Iterator(java.util.Iterator) Viewer(org.eclipse.jface.viewers.Viewer) Action(org.eclipse.jface.action.Action) TestResult(org.eclipse.n4js.tester.domain.TestResult) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewerBuilder(org.eclipse.n4js.ui.viewer.TreeViewerBuilder) ToolBarManager(org.eclipse.jface.action.ToolBarManager) Menu(org.eclipse.swt.widgets.Menu) LabelProvider(org.eclipse.jface.viewers.LabelProvider) Control(org.eclipse.swt.widgets.Control) TestConfiguration(org.eclipse.n4js.tester.TestConfiguration) PartInitException(org.eclipse.ui.PartInitException)

Example 3 with TestConfiguration

use of org.eclipse.n4js.tester.TestConfiguration 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

TestConfiguration (org.eclipse.n4js.tester.TestConfiguration)3 TestTree (org.eclipse.n4js.tester.domain.TestTree)2 Joiner (com.google.common.base.Joiner)1 Strings (com.google.common.base.Strings)1 Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)1 FluentIterable.from (com.google.common.collect.FluentIterable.from)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 AllowConcurrentEvents (com.google.common.eventbus.AllowConcurrentEvents)1 Subscribe (com.google.common.eventbus.Subscribe)1 Ints.asList (com.google.common.primitives.Ints.asList)1 Inject (com.google.inject.Inject)1 System.lineSeparator (java.lang.System.lineSeparator)1 ArrayList (java.util.ArrayList)1 Arrays.copyOfRange (java.util.Arrays.copyOfRange)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 IFile (org.eclipse.core.resources.IFile)1 SEPARATOR (org.eclipse.core.runtime.IPath.SEPARATOR)1 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)1