From 6db03c068a2f946b4d2374ceb0d5d55c5146db70 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 16 Apr 2015 17:48:23 +0200 Subject: [PATCH] sm-runner: parameters in overrides replaced with console properties --- .../JavaAwareTestConsoleProperties.java | 5 +- .../sm/SMTestRunnerConnectionUtil.java | 122 ++++++++++++------ .../sm/runner/SMTRunnerConsoleProperties.java | 42 ++++-- 3 files changed, 116 insertions(+), 53 deletions(-) diff --git a/java/execution/impl/src/com/intellij/execution/testframework/JavaAwareTestConsoleProperties.java b/java/execution/impl/src/com/intellij/execution/testframework/JavaAwareTestConsoleProperties.java index 4c4c6e1e2eaa..a88f15d5c6cf 100644 --- a/java/execution/impl/src/com/intellij/execution/testframework/JavaAwareTestConsoleProperties.java +++ b/java/execution/impl/src/com/intellij/execution/testframework/JavaAwareTestConsoleProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,8 @@ import java.util.Collection; public abstract class JavaAwareTestConsoleProperties & CommonJavaRunConfigurationParameters> extends SMTRunnerConsoleProperties { public JavaAwareTestConsoleProperties(final String testFrameworkName, RunConfiguration configuration, Executor executor) { - super(configuration, testFrameworkName, executor, false); + super(configuration, testFrameworkName, executor); + setPrintTestingStartedTime(false); } @Override diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java index 832d31bf1479..2b4f919e45f8 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/SMTestRunnerConnectionUtil.java @@ -89,6 +89,7 @@ public class SMTestRunnerConnectionUtil { * @throws ExecutionException If IDEA cannot execute process this exception will * be caught and shown in error message box */ + @NotNull public static BaseTestsOutputConsoleView createAndAttachConsole(@NotNull String testFrameworkName, @NotNull ProcessHandler processHandler, @NotNull TestConsoleProperties consoleProperties, @@ -98,28 +99,13 @@ public class SMTestRunnerConnectionUtil { return console; } + @NotNull public static BaseTestsOutputConsoleView createConsole(@NotNull String testFrameworkName, @NotNull TestConsoleProperties consoleProperties, ExecutionEnvironment environment) { - return createConsoleWithCustomLocator(testFrameworkName, consoleProperties, environment, null); - } - - public static BaseTestsOutputConsoleView createConsoleWithCustomLocator(@NotNull String testFrameworkName, - @NotNull TestConsoleProperties consoleProperties, - ExecutionEnvironment environment, - @SuppressWarnings("deprecation") @Nullable TestLocationProvider locator) { - return createConsoleWithCustomLocator(testFrameworkName, consoleProperties, environment, locator, false, null); - } - - public static SMTRunnerConsoleView createConsoleWithCustomLocator(@NotNull String testFrameworkName, - @NotNull TestConsoleProperties consoleProperties, - ExecutionEnvironment environment, - @SuppressWarnings("deprecation") @Nullable TestLocationProvider locator, - boolean idBasedTreeConstruction, - @Nullable TestProxyFilterProvider filterProvider) { String splitterPropertyName = getSplitterPropertyName(testFrameworkName); SMTRunnerConsoleView consoleView = new SMTRunnerConsoleView(consoleProperties, environment, splitterPropertyName); - initConsoleView(consoleView, testFrameworkName, locator, idBasedTreeConstruction, filterProvider); + initConsoleView(consoleView, testFrameworkName); return consoleView; } @@ -128,30 +114,31 @@ public class SMTestRunnerConnectionUtil { return testFrameworkName + ".Splitter.Proportion"; } - public static void initConsoleView(@NotNull final SMTRunnerConsoleView consoleView, - @NotNull final String testFrameworkName, - @SuppressWarnings("deprecation") @Nullable final TestLocationProvider locator, - final boolean idBasedTreeConstruction, - @Nullable final TestProxyFilterProvider filterProvider) { + public static void initConsoleView(@NotNull final SMTRunnerConsoleView consoleView, @NotNull final String testFrameworkName) { consoleView.addAttachToProcessListener(new AttachToProcessListener() { @Override public void onAttachToProcess(@NotNull ProcessHandler processHandler) { - TestProxyPrinterProvider printerProvider = null; - if (filterProvider != null) { - printerProvider = new TestProxyPrinterProvider(consoleView, filterProvider); - } - TestConsoleProperties properties = consoleView.getProperties(); - SMTestLocator testLocator = null; + TestProxyPrinterProvider printerProvider = null; if (properties instanceof SMTRunnerConsoleProperties) { - testLocator = ((SMTRunnerConsoleProperties)properties).getTestLocator(); + TestProxyFilterProvider filterProvider = ((SMTRunnerConsoleProperties)properties).getFilterProvider(); + if (filterProvider != null) { + printerProvider = new TestProxyPrinterProvider(consoleView, filterProvider); + } } - if (testLocator != null) { - testLocator = new CombinedTestLocator(testLocator); // new API in action + + SMTestLocator testLocator = FileUrlProvider.INSTANCE; + if (properties instanceof SMTRunnerConsoleProperties) { + SMTestLocator customLocator = ((SMTRunnerConsoleProperties)properties).getTestLocator(); + if (customLocator != null) { + testLocator = new CombinedTestLocator(customLocator); + } } - else { - testLocator = new CompositeTestLocationProvider(locator); // legacy mode + + boolean idBasedTestTree = false; + if (properties instanceof SMTRunnerConsoleProperties) { + idBasedTestTree = ((SMTRunnerConsoleProperties)properties).isIdBasedTestTree(); } SMTestRunnerResultsForm resultsForm = consoleView.getResultsViewer(); @@ -161,7 +148,7 @@ public class SMTestRunnerConnectionUtil { processHandler, testFrameworkName, testLocator, - idBasedTreeConstruction, + idBasedTestTree, printerProvider); } }); @@ -180,13 +167,13 @@ public class SMTestRunnerConnectionUtil { return Boolean.valueOf(System.getProperty(TEST_RUNNER_DEBUG_MODE_PROPERTY)); } - private static ProcessHandler attachEventsProcessors(@NotNull TestConsoleProperties consoleProperties, + private static ProcessHandler attachEventsProcessors(TestConsoleProperties consoleProperties, SMTestRunnerResultsForm resultsViewer, StatisticsPanel statisticsPane, ProcessHandler processHandler, - @NotNull String testFrameworkName, + String testFrameworkName, @Nullable SMTestLocator locator, - boolean idBasedTreeConstruction, + boolean idBasedTestTree, @Nullable TestProxyPrinterProvider printerProvider) { // build messages consumer final OutputToGeneralTestEventsConverter outputConsumer; @@ -199,15 +186,17 @@ public class SMTestRunnerConnectionUtil { // events processor final GeneralTestEventsProcessor eventsProcessor; - if (idBasedTreeConstruction) { + if (idBasedTestTree) { eventsProcessor = new GeneralIdBasedToSMTRunnerEventsConvertor(resultsViewer.getTestsRootNode(), testFrameworkName); } else { eventsProcessor = new GeneralToSMTRunnerEventsConvertor(resultsViewer.getTestsRootNode(), testFrameworkName); } + if (locator != null) { eventsProcessor.setLocator(locator); } + if (printerProvider != null) { eventsProcessor.setPrinterProvider(printerProvider); } @@ -276,6 +265,63 @@ public class SMTestRunnerConnectionUtil { } } + /** @deprecated use {@link #createConsole(String, TestConsoleProperties, ExecutionEnvironment)} (to be removed in IDEA 16) */ + @SuppressWarnings({"unused", "deprecation"}) + public static BaseTestsOutputConsoleView createConsoleWithCustomLocator(@NotNull String testFrameworkName, + @NotNull TestConsoleProperties consoleProperties, + ExecutionEnvironment environment, + @Nullable TestLocationProvider locator) { + return createConsoleWithCustomLocator(testFrameworkName, consoleProperties, environment, locator, false, null); + } + + /** @deprecated use {@link #createConsole(String, TestConsoleProperties, ExecutionEnvironment)} (to be removed in IDEA 16) */ + @SuppressWarnings({"unused", "deprecation"}) + public static SMTRunnerConsoleView createConsoleWithCustomLocator(@NotNull String testFrameworkName, + @NotNull TestConsoleProperties consoleProperties, + ExecutionEnvironment environment, + @Nullable TestLocationProvider locator, + boolean idBasedTreeConstruction, + @Nullable TestProxyFilterProvider filterProvider) { + String splitterPropertyName = getSplitterPropertyName(testFrameworkName); + SMTRunnerConsoleView consoleView = new SMTRunnerConsoleView(consoleProperties, environment, splitterPropertyName); + initConsoleView(consoleView, testFrameworkName, locator, idBasedTreeConstruction, filterProvider); + return consoleView; + } + + /** @deprecated use {@link #initConsoleView(SMTRunnerConsoleView, String)} (to be removed in IDEA 16) */ + @SuppressWarnings({"unused", "deprecation"}) + public static void initConsoleView(@NotNull final SMTRunnerConsoleView consoleView, + @NotNull final String testFrameworkName, + @Nullable final TestLocationProvider locator, + final boolean idBasedTreeConstruction, + @Nullable final TestProxyFilterProvider filterProvider) { + consoleView.addAttachToProcessListener(new AttachToProcessListener() { + @Override + public void onAttachToProcess(@NotNull ProcessHandler processHandler) { + TestConsoleProperties properties = consoleView.getProperties(); + + SMTestLocator testLocator = new CompositeTestLocationProvider(locator); + + TestProxyPrinterProvider printerProvider = null; + if (filterProvider != null) { + printerProvider = new TestProxyPrinterProvider(consoleView, filterProvider); + } + + SMTestRunnerResultsForm resultsForm = consoleView.getResultsViewer(); + attachEventsProcessors(properties, + resultsForm, + resultsForm.getStatisticsPane(), + processHandler, + testFrameworkName, + testLocator, + idBasedTreeConstruction, + printerProvider); + } + }); + consoleView.setHelpId("reference.runToolWindow.testResultsTab"); + consoleView.initUI(); + } + /** @deprecated use {@link #createAndAttachConsole(String, ProcessHandler, TestConsoleProperties, ExecutionEnvironment)} (to be removed in IDEA 16) */ @SuppressWarnings("unused") public static ConsoleView createAndAttachConsole(@NotNull String testFrameworkName, diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleProperties.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleProperties.java index 0ca074bf4e75..aec62fe1b861 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleProperties.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTRunnerConsoleProperties.java @@ -40,12 +40,13 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** - * @author: Roman Chernyatchik + * @author Roman Chernyatchik */ public class SMTRunnerConsoleProperties extends TestConsoleProperties implements SMStacktraceParser { private final RunConfiguration myConfiguration; - protected final CompositeFilter myCustomFilter; - private final boolean myPrintTestingStartedTime; + private final CompositeFilter myCustomFilter; + private boolean myIdBasedTestTree = false; + private boolean myPrintTestingStartedTime = true; /** * @param config @@ -53,22 +54,19 @@ public class SMTRunnerConsoleProperties extends TestConsoleProperties implements * @param executor */ public SMTRunnerConsoleProperties(@NotNull RunConfiguration config, @NotNull String testFrameworkName, @NotNull Executor executor) { - this(config, testFrameworkName, executor, true); + super(getStorage(testFrameworkName), config.getProject(), executor); + myConfiguration = config; + myCustomFilter = new CompositeFilter(config.getProject()); } - /** - * @param config - * @param testFrameworkName Prefix for storage which keeps runner settings. E.g. "RubyTestUnit" - * @param executor - */ + /** @deprecated {@use #setPrintTestingStartedTime} (to be removed in IDEA 16) */ + @SuppressWarnings("unused") public SMTRunnerConsoleProperties(@NotNull RunConfiguration config, @NotNull String testFrameworkName, @NotNull Executor executor, boolean printTestingStartedTime) { - super(getStorage(testFrameworkName), config.getProject(), executor); - myConfiguration = config; - myCustomFilter = new CompositeFilter(config.getProject()); - myPrintTestingStartedTime = printTestingStartedTime; + this(config, testFrameworkName, executor); + setPrintTestingStartedTime(printTestingStartedTime); } @NotNull @@ -76,14 +74,27 @@ public class SMTRunnerConsoleProperties extends TestConsoleProperties implements return new Storage.PropertiesComponentStorage(testFrameworkName + "Support.", PropertiesComponent.getInstance()); } + @Override public RunConfiguration getConfiguration() { return myConfiguration; } + public boolean isIdBasedTestTree() { + return myIdBasedTestTree; + } + + public void setIdBasedTestTree(boolean idBasedTestTree) { + myIdBasedTestTree = idBasedTestTree; + } + public boolean isPrintTestingStartedTime() { return myPrintTestingStartedTime; } + public void setPrintTestingStartedTime(boolean printTestingStartedTime) { + myPrintTestingStartedTime = printTestingStartedTime; + } + @Override public Navigatable getErrorNavigatable(@NotNull final Project project, final @NotNull String stacktrace) { if (myCustomFilter.isEmpty()) { @@ -167,4 +178,9 @@ public class SMTRunnerConsoleProperties extends TestConsoleProperties implements public SMTestLocator getTestLocator() { return null; } + + @Nullable + public TestProxyFilterProvider getFilterProvider() { + return null; + } }