From 5e0305f9d36d9e4e91f627668d14428b1ae3c3b9 Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Thu, 7 May 2015 14:26:46 +0300 Subject: [PATCH 01/27] Test stoud fixed for PY-12621 --- python/helpers/pycharm/pytest_teamcity.py | 1 + python/helpers/pycharm/pytestrunner.py | 6 ++- .../testData/testRunner/env/pytest/test2.py | 5 ++ .../python/testing/PythonPyTestingTest.java | 11 ++-- .../com/jetbrains/env/ut/PyUnitTestTask.java | 53 ++++++++++++++++++- 5 files changed, 70 insertions(+), 6 deletions(-) diff --git a/python/helpers/pycharm/pytest_teamcity.py b/python/helpers/pycharm/pytest_teamcity.py index 2eaa15cf37a4..8860257027d9 100644 --- a/python/helpers/pycharm/pytest_teamcity.py +++ b/python/helpers/pycharm/pytest_teamcity.py @@ -80,6 +80,7 @@ if PYVERSION > [1, 4, 0]: messages.testIgnored(name) elif report.failed: messages.testFailed(name, details=report.longrepr) + messages.testFinished(name) # We need to mark it finished even if it failed to display it at parent node elif report.when == "call": messages.testFinished(name) diff --git a/python/helpers/pycharm/pytestrunner.py b/python/helpers/pycharm/pytestrunner.py index 0725e2f11ff2..6b2bdd61f552 100644 --- a/python/helpers/pycharm/pytestrunner.py +++ b/python/helpers/pycharm/pytestrunner.py @@ -20,10 +20,13 @@ def get_plugin_manager(): from _pytest.core import PluginManager return PluginManager(load=True) +# "-s" is always required: no test output provided otherwise +args = sys.argv[1:] +args.append("-s") if "-s" not in args else None + if has_pytest: _preinit = [] def main(): - args = sys.argv[1:] _pluginmanager = get_plugin_manager() hook = _pluginmanager.hook try: @@ -38,7 +41,6 @@ if has_pytest: else: def main(): - args = sys.argv[1:] config = py.test.config try: config.parse(args) diff --git a/python/testData/testRunner/env/pytest/test2.py b/python/testData/testRunner/env/pytest/test2.py index b6c7b0887aa9..bcac55af6286 100644 --- a/python/testData/testRunner/env/pytest/test2.py +++ b/python/testData/testRunner/env/pytest/test2.py @@ -1,10 +1,15 @@ class TestPyTest: def testOne(self): + print("I am test1") assert 5 == 2*2 def testTwo(self): assert True + def testFail(self): + print("I will fail") + assert False + def testThree(): assert 4 == 2*2 diff --git a/python/testSrc/com/jetbrains/env/python/testing/PythonPyTestingTest.java b/python/testSrc/com/jetbrains/env/python/testing/PythonPyTestingTest.java index ab3dee60c5b0..6eaf2a872c02 100644 --- a/python/testSrc/com/jetbrains/env/python/testing/PythonPyTestingTest.java +++ b/python/testSrc/com/jetbrains/env/python/testing/PythonPyTestingTest.java @@ -2,11 +2,13 @@ package com.jetbrains.env.python.testing; import com.jetbrains.env.PyEnvTestCase; import com.jetbrains.env.ut.PyTestTestTask; +import org.hamcrest.Matchers; +import org.junit.Assert; /** * User : catherine */ -public class PythonPyTestingTest extends PyEnvTestCase{ +public class PythonPyTestingTest extends PyEnvTestCase { public void testPytestRunner() { runPythonTest(new PyTestTestTask("/testRunner/env/pytest", "test1.py") { @@ -24,9 +26,12 @@ public class PythonPyTestingTest extends PyEnvTestCase{ @Override public void after() { - assertEquals(8, allTestsCount()); + assertEquals(9, allTestsCount()); assertEquals(5, passedTestsCount()); - assertEquals(3, failedTestsCount()); + assertEquals(4, failedTestsCount()); + Assert.assertThat("No test stdout", getMockPrinter(findTestByName("testOne")).getStdOut(), Matchers.startsWith("I am test1")); + // Ensure test has stdout even it fails + Assert.assertThat("No stdout for fail", getMockPrinter(findTestByName("testFail")).getStdOut(), Matchers.startsWith("I will fail")); } }); } diff --git a/python/testSrc/com/jetbrains/env/ut/PyUnitTestTask.java b/python/testSrc/com/jetbrains/env/ut/PyUnitTestTask.java index 2615c75ae036..e300a1e69255 100644 --- a/python/testSrc/com/jetbrains/env/ut/PyUnitTestTask.java +++ b/python/testSrc/com/jetbrains/env/ut/PyUnitTestTask.java @@ -13,8 +13,11 @@ import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.execution.runners.ExecutionEnvironmentBuilder; import com.intellij.execution.runners.ProgramRunner; +import com.intellij.execution.testframework.AbstractTestProxy; import com.intellij.execution.testframework.Filter; +import com.intellij.execution.testframework.Printable; import com.intellij.execution.testframework.sm.runner.SMTestProxy; +import com.intellij.execution.testframework.sm.runner.ui.MockPrinter; import com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView; import com.intellij.execution.testframework.sm.runner.ui.TestResultsViewer; import com.intellij.execution.ui.RunContentDescriptor; @@ -190,7 +193,7 @@ public abstract class PyUnitTestTask extends PyExecutionFixtureTestTask { * Run configuration. * * @param settings settings (if have any, null otherwise) - * @param config configuration to run + * @param config configuration to run * @throws Exception */ protected void runConfiguration(@Nullable final RunnerAndConfigurationSettings settings, @@ -271,6 +274,54 @@ public abstract class PyUnitTestTask extends PyExecutionFixtureTestTask { Assert.assertEquals(output(), 0, failedTestsCount()); } + /** + * Creates {@link MockPrinter} filled with test output. Use it to check what output test has. + * + * @param test test to fill mock printer with + * @return filled print. + */ + @NotNull + protected static MockPrinter getMockPrinter(@NotNull final Printable test) { + final MockPrinter printer = new MockPrinter(); + test.printOn(printer); + return printer; + } + + /** + * Searches for test by its name recursevly in {@link #myTestProxy} + * + * @param testName test name to find + * @return test + * @throws AssertionError if no test found + */ + @NotNull + public AbstractTestProxy findTestByName(@NotNull final String testName) { + final AbstractTestProxy test = findTestByName(testName, myTestProxy); + assert test != null : "No test found with name" + testName; + return test; + } + + /** + * Searches for test by its name recursevly in test, passed as arumuent. + * + * @param testName test name to find + * @param test root test + * @return test or null if not found + */ + @Nullable + private static AbstractTestProxy findTestByName(@NotNull final String testName, @NotNull final AbstractTestProxy test) { + if (test.getName().equals(testName)) { + return test; + } + for (final AbstractTestProxy testProxy : test.getChildren()) { + final AbstractTestProxy result = findTestByName(testName, testProxy); + if (result != null) { + return result; + } + } + return null; + } + public int failedTestsCount() { return myTestProxy.collectChildren(NOT_SUIT.and(Filter.FAILED_OR_INTERRUPTED)).size(); } From efceab83ad9e9f6ef0073c186c4b9fd159036b4b Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Thu, 7 May 2015 14:28:45 +0300 Subject: [PATCH 02/27] Revert "use PsiModificationTracker#getModificationCount so we won't get same modification count after stub/ast switch accidentally" This reverts commit 48217a564a00ba726a61680ea2682e32c87c465f. --- .../StructureViewComponent.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java index c03f11b94e97..ac5eef43e7cf 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java @@ -37,15 +37,13 @@ import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.SimpleToolWindowPanel; -import com.intellij.openapi.util.AsyncResult; -import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.Key; +import com.intellij.openapi.util.*; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.pom.Navigatable; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiManager; +import com.intellij.psi.StubBasedPsiElement; +import com.intellij.psi.impl.source.tree.CompositeElement; import com.intellij.psi.util.PsiUtilCore; import com.intellij.ui.*; import com.intellij.ui.treeStructure.actions.CollapseAllAction; @@ -826,7 +824,15 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre modificationCountForChildren = ourSettingsModificationCount; } - final long currentStamp = myProject != null ? PsiManager.getInstance(myProject).getModificationTracker().getModificationCount() : -1; + final Object o = unwrapValue(getValue()); + long currentStamp = -1; + if (o instanceof StubBasedPsiElement && ((StubBasedPsiElement)o).getStub() != null) { + currentStamp = ((StubBasedPsiElement)o).getContainingFile().getModificationStamp(); + } else if (o instanceof PsiElement && ((PsiElement)o).getNode() instanceof CompositeElement) { + currentStamp = ((CompositeElement)((PsiElement)o).getNode()).getModificationCount(); + } else if (o instanceof ModificationTracker) { + currentStamp = ((ModificationTracker)o).getModificationCount(); + } if (childrenStamp != currentStamp) { resetChildren(); childrenStamp = currentStamp; From 5295661a0b8162de75faece61347fc3ae7a0354c Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Thu, 7 May 2015 14:24:18 +0300 Subject: [PATCH 03/27] complete processing instructions --- .../impl/source/xml/DefaultXmlTagNameProvider.java | 12 ++++++++++++ .../codeInsight/completion/XmlCompletionTest.java | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/DefaultXmlTagNameProvider.java b/xml/impl/src/com/intellij/psi/impl/source/xml/DefaultXmlTagNameProvider.java index da79a6000e2d..8ffdc879bc3b 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/DefaultXmlTagNameProvider.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/DefaultXmlTagNameProvider.java @@ -15,6 +15,8 @@ */ package com.intellij.psi.impl.source.xml; +import com.intellij.codeInsight.AutoPopupController; +import com.intellij.codeInsight.completion.InsertHandler; import com.intellij.codeInsight.completion.InsertionContext; import com.intellij.codeInsight.completion.PrioritizedLookupElement; import com.intellij.codeInsight.completion.XmlTagInsertHandler; @@ -100,6 +102,16 @@ public class DefaultXmlTagNameProvider implements XmlTagNameProvider { } private static List getRootTagsVariants(final XmlTag tag, final List elements) { + + elements.add(LookupElementBuilder.create("?xml version=\"1.0\" encoding=\"\" ?>").withPresentableText("").withInsertHandler( + new InsertHandler() { + @Override + public void handleInsert(InsertionContext context, LookupElement item) { + int offset = context.getEditor().getCaretModel().getOffset(); + context.getEditor().getCaretModel().moveToOffset(offset - 4); + AutoPopupController.getInstance(context.getProject()).scheduleAutoPopup(context.getEditor()); + } + })); final FileBasedIndex fbi = FileBasedIndex.getInstance(); CommonProcessors.CollectProcessor processor = new CommonProcessors.CollectProcessor(); fbi.processAllKeys(XmlNamespaceIndex.NAME, processor, tag.getProject()); diff --git a/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java b/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java index 2bc97c114cce..bb831e5fec88 100644 --- a/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java +++ b/xml/tests/src/com/intellij/codeInsight/completion/XmlCompletionTest.java @@ -743,5 +743,13 @@ public class XmlCompletionTest extends LightCodeInsightFixtureTestCase { CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = old; } } + + public void testPi() throws Exception { + myFixture.configureByText("foo.xml", "<"); + myFixture.completeBasic(); + myFixture.type('?'); + myFixture.type('\n'); + myFixture.checkResult("\" ?>"); + } } From a915733df20a52808627e2750b9784278c83e255 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 7 May 2015 13:09:11 +0200 Subject: [PATCH 04/27] sm runner: format time from junit --- .../sm/runner/ui/TestsPresentationUtil.java | 30 ++++++++++++++++++- .../ui/statistics/ColumnDurationTest.java | 24 +++++++-------- .../execution/junit2/ui/ActualStatistics.java | 3 +- .../execution/junit2/ui/Formatters.java | 26 ---------------- .../junit2/ui/model/CompletionEvent.java | 4 +-- 5 files changed, 45 insertions(+), 42 deletions(-) diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/TestsPresentationUtil.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/TestsPresentationUtil.java index ed7789e236a9..10f38eb49020 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/TestsPresentationUtil.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/TestsPresentationUtil.java @@ -15,6 +15,7 @@ */ package com.intellij.execution.testframework.sm.runner.ui; +import com.intellij.execution.ExecutionBundle; import com.intellij.execution.process.AnsiEscapeDecoder; import com.intellij.execution.process.ProcessOutputTypes; import com.intellij.execution.testframework.PoolOfTestIcons; @@ -37,6 +38,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; +import java.text.NumberFormat; import java.util.List; import java.util.Set; @@ -427,7 +429,7 @@ public class TestsPresentationUtil { } else if (duration < 100) { return String.valueOf(duration) + MILLISECONDS_SUFFIX; } else { - return String.valueOf(duration.floatValue() / 1000) + SECONDS_SUFFIX; + return printTime(duration); } } @@ -474,4 +476,30 @@ public class TestsPresentationUtil { } }); } + + public static String printTime(final long milliseconds) { + if (milliseconds == 0) { + return ExecutionBundle.message("junit.runing.info.time.sec.message", "0.0"); + } + long seconds = milliseconds / 1000; + if (seconds == 0) { + return ExecutionBundle.message("junit.runing.info.time.sec.message", NumberFormat.getInstance().format((double)milliseconds/1000.0)); + } + + final StringBuilder sb = new StringBuilder(); + if (seconds >= 3600) { + sb.append(seconds / 3600).append(" h "); + seconds %= 3600; + } + + if (seconds >= 60) { + sb.append(seconds / 60).append(" m "); + seconds %= 60; + } + + if (seconds > 0 || sb.length() > 0) { + sb.append(seconds).append(" s"); + } + return sb.toString(); + } } diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/ColumnDurationTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/ColumnDurationTest.java index 8e554be5b303..e3b5b73b29ce 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/ColumnDurationTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/ColumnDurationTest.java @@ -41,7 +41,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest { assertEquals("", myColumn.valueOf(mySimpleTest)); mySimpleTest.setDuration(10000); - assertEquals(String.valueOf((float)10) + " s", myColumn.valueOf(mySimpleTest)); + assertEquals("10 s", myColumn.valueOf(mySimpleTest)); } public void testValueOf_TestPassed() { @@ -50,7 +50,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest { assertEquals("", myColumn.valueOf(mySimpleTest)); mySimpleTest.setDuration(10000); - assertEquals(String.valueOf((float)10) + " s", myColumn.valueOf(mySimpleTest)); + assertEquals("10 s", myColumn.valueOf(mySimpleTest)); } public void testValueOf_TestError() { @@ -59,7 +59,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest { assertEquals("", myColumn.valueOf(mySimpleTest)); mySimpleTest.setDuration(10000); - assertEquals(String.valueOf((float)10) + " s", myColumn.valueOf(mySimpleTest)); + assertEquals("10 s", myColumn.valueOf(mySimpleTest)); } public void testValueOf_TestTerminated() { @@ -68,7 +68,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest { assertEquals("", myColumn.valueOf(mySimpleTest)); mySimpleTest.setDuration(10000); - assertEquals("TERMINATED: " + String.valueOf((float)10) + " s", myColumn.valueOf(mySimpleTest)); + assertEquals("TERMINATED: 10 s", myColumn.valueOf(mySimpleTest)); } public void testValueOf_TestIgnored() { @@ -78,7 +78,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest { assertEquals("", myColumn.valueOf(mySimpleTest)); mySimpleTest.setDuration(10000); - assertEquals(String.valueOf((float)10) + " s", myColumn.valueOf(mySimpleTest)); + assertEquals("10 s", myColumn.valueOf(mySimpleTest)); } public void testValueOf_Duration_Zero() { @@ -132,7 +132,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest { assertEquals("", myColumn.valueOf(mySimpleTest)); mySimpleTest.setDuration(1000); - assertEquals(String.valueOf((float)1) + " s", myColumn.valueOf(mySimpleTest)); + assertEquals("1 s", myColumn.valueOf(mySimpleTest)); } public void testValueOf_Duration_1001() { @@ -141,7 +141,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest { assertEquals("", myColumn.valueOf(mySimpleTest)); mySimpleTest.setDuration(1001); - assertEquals(String.valueOf((float)1.001) + " s", myColumn.valueOf(mySimpleTest)); + assertEquals("1 s", myColumn.valueOf(mySimpleTest)); } public void testValueOf_SuiteEmpty() { @@ -176,7 +176,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest { assertEquals("", myColumn.valueOf(suite)); test.setDuration(10000); - assertEquals(String.valueOf((float)10) + " s", myColumn.valueOf(suite)); + assertEquals("10 s", myColumn.valueOf(suite)); } public void testValueOf_SuiteError() { @@ -190,7 +190,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest { assertEquals("", myColumn.valueOf(suite)); test.setDuration(10000); - assertEquals(String.valueOf((float)10) + " s", myColumn.valueOf(suite)); + assertEquals("10 s", myColumn.valueOf(suite)); } public void testValueOf_SuitePassed() { @@ -204,7 +204,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest { assertEquals("", myColumn.valueOf(suite)); test.setDuration(10000); - assertEquals(String.valueOf((float)10) + " s", myColumn.valueOf(suite)); + assertEquals("10 s", myColumn.valueOf(suite)); } public void testValueOf_SuiteTerminated() { @@ -217,7 +217,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest { assertEquals("", myColumn.valueOf(suite)); test.setDuration(10000); - assertEquals("TERMINATED: " + String.valueOf((float)10) + " s", myColumn.valueOf(suite)); + assertEquals("TERMINATED: 10 s", myColumn.valueOf(suite)); } public void testValueOf_SuiteRunning() { @@ -230,7 +230,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest { assertEquals("", myColumn.valueOf(suite)); test.setDuration(10000); - assertEquals("RUNNING: " + String.valueOf((float)10) + " s", myColumn.valueOf(suite)); + assertEquals("RUNNING: 10 s", myColumn.valueOf(suite)); } public void testTotal_Test() { diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/ActualStatistics.java b/plugins/junit/src/com/intellij/execution/junit2/ui/ActualStatistics.java index e086143885b9..2d43567e3b8a 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/ActualStatistics.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/ActualStatistics.java @@ -18,6 +18,7 @@ package com.intellij.execution.junit2.ui; import com.intellij.execution.junit2.states.CumulativeStatistics; import com.intellij.execution.junit2.states.Statistics; +import com.intellij.execution.testframework.sm.runner.ui.TestsPresentationUtil; class ActualStatistics implements TestStatistics { private final CumulativeStatistics myStatistics = new CumulativeStatistics(); @@ -32,7 +33,7 @@ class ActualStatistics implements TestStatistics { } public String getTime() { - return myPrefix + Formatters.printTime(myStatistics.getTime()); + return myPrefix + TestsPresentationUtil.printTime(myStatistics.getTime()); } public String getMemoryUsageDelta() { diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/Formatters.java b/plugins/junit/src/com/intellij/execution/junit2/ui/Formatters.java index 700563fd1233..7727b9968ccb 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/Formatters.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/Formatters.java @@ -32,32 +32,6 @@ public class Formatters { return info.getName() + sensibleCommentFor(test); } - public static String printTime(final long milliseconds) { - if (milliseconds == 0) { - return ExecutionBundle.message("junit.runing.info.time.sec.message", "0.0"); - } - long seconds = milliseconds / 1000; - if (seconds == 0) { - return ExecutionBundle.message("junit.runing.info.time.sec.message", NumberFormat.getInstance().format((double)milliseconds/1000.0)); - } - - final StringBuilder sb = new StringBuilder(); - if (seconds >= 3600) { - sb.append(seconds / 3600).append("h "); - seconds %= 3600; - } - - if (seconds >= 60) { - sb.append(seconds / 60).append("m "); - seconds %= 60; - } - - if (seconds > 0 || sb.length() > 0) { - sb.append(seconds).append("s"); - } - return sb.toString(); - } - public static String printMemory(final long memory) { final String string = printMemoryUnsigned(memory); return memory > 0 ? "+" + string : string; diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/model/CompletionEvent.java b/plugins/junit/src/com/intellij/execution/junit2/ui/model/CompletionEvent.java index 8a0b297a65e1..2f8f5eb78699 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/model/CompletionEvent.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/model/CompletionEvent.java @@ -16,14 +16,14 @@ package com.intellij.execution.junit2.ui.model; -import com.intellij.execution.junit2.ui.Formatters; +import com.intellij.execution.testframework.sm.runner.ui.TestsPresentationUtil; public class CompletionEvent extends StateEvent { private final boolean myNormalExit; public CompletionEvent(final boolean normalExit, final long time) { super(normalExit ? TerminatedType.DONE: TerminatedType.TERNINATED, - time >= 0 ? "in " + Formatters.printTime(time) : ""); + time >= 0 ? "in " + TestsPresentationUtil.printTime(time) : ""); myNormalExit = normalExit; } From 02737f972441f8ec55f67092c2c2f969c66085e4 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 7 May 2015 13:41:52 +0200 Subject: [PATCH 05/27] java sm runner: navigate from test root --- .../sm/runner/GeneralTestEventsProcessor.java | 2 +- .../GeneralToSMTRunnerEventsConvertor.java | 6 ++++- .../OutputToGeneralTestEventsConverter.java | 6 ++--- .../testframework/sm/runner/SMTestProxy.java | 23 ++++++++++++++++--- .../src/com/intellij/junit4/SMTestSender.java | 3 ++- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java index a53a5a9bcd5f..43562be8ddea 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralTestEventsProcessor.java @@ -50,7 +50,7 @@ public abstract class GeneralTestEventsProcessor implements Disposable { // tree construction events - public void onRootPresentationAdded(String rootName, String comment) {} + public void onRootPresentationAdded(String rootName, String comment, String rootLocation) {} public void onSuiteTreeNodeAdded(String testName, String locationHint) { } diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java index 92743bafdf24..c079b43f30ab 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/GeneralToSMTRunnerEventsConvertor.java @@ -115,12 +115,16 @@ public class GeneralToSMTRunnerEventsConvertor extends GeneralTestEventsProcesso } @Override - public void onRootPresentationAdded(final String rootName, final String comment) { + public void onRootPresentationAdded(final String rootName, final String comment, final String rootLocation) { addToInvokeLater(new Runnable() { @Override public void run() { myTestsRootNode.setPresentation(rootName); myTestsRootNode.setComment(comment); + myTestsRootNode.setRootLocationUrl(rootLocation); + if (myLocator != null) { + myTestsRootNode.setLocator(myLocator); + } } }); } diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/OutputToGeneralTestEventsConverter.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/OutputToGeneralTestEventsConverter.java index 02a6ec568fca..785f83065438 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/OutputToGeneralTestEventsConverter.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/OutputToGeneralTestEventsConverter.java @@ -215,10 +215,10 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer } - private void fireRootPresentationAdded(String rootName, @Nullable String comment) { + private void fireRootPresentationAdded(String rootName, @Nullable String comment, String rootLocation) { final GeneralTestEventsProcessor processor = myProcessor; if (processor != null) { - processor.onRootPresentationAdded(rootName, comment); + processor.onRootPresentationAdded(rootName, comment, rootLocation); } } @@ -501,7 +501,7 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer } else if (ROOT_PRESENTATION.equals(name)) { final Map attributes = msg.getAttributes(); - fireRootPresentationAdded(attributes.get("name"), attributes.get("comment")); + fireRootPresentationAdded(attributes.get("name"), attributes.get("comment"), attributes.get("location")); } else { GeneralToSMTRunnerEventsConvertor.logProblem(LOG, "Unexpected service message:" + name, myTestFrameworkName); diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java index 62abe559587b..c6456630398b 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/SMTestProxy.java @@ -267,10 +267,15 @@ public class SMTestProxy extends AbstractTestProxy { @Nullable public Location getLocation(@NotNull Project project, @NotNull GlobalSearchScope searchScope) { //determines location of test proxy - if (myLocationUrl != null && myLocator != null) { - String protocolId = VirtualFileManager.extractProtocol(myLocationUrl); + final String locationUrl = myLocationUrl; + return getLocation(project, searchScope, locationUrl); + } + + protected Location getLocation(@NotNull Project project, @NotNull GlobalSearchScope searchScope, String locationUrl) { + if (locationUrl != null && myLocator != null) { + String protocolId = VirtualFileManager.extractProtocol(locationUrl); if (protocolId != null) { - String path = VirtualFileManager.extractPath(myLocationUrl); + String path = VirtualFileManager.extractPath(locationUrl); if (!DumbService.isDumb(project) || DumbService.isDumbAware(myLocator)) { List locations = myLocator.getLocation(protocolId, path, project, searchScope); if (!locations.isEmpty()) { @@ -742,6 +747,7 @@ public class SMTestProxy extends AbstractTestProxy { private String myPresentation; private String myComment; + private String myRootLocationUrl; public SMRootTestProxy() { super("[root]", true, null); @@ -771,6 +777,17 @@ public class SMTestProxy extends AbstractTestProxy { return myComment; } + public void setRootLocationUrl(String locationUrl) { + myRootLocationUrl = locationUrl; + } + + @Nullable + @Override + public Location getLocation(@NotNull Project project, @NotNull GlobalSearchScope searchScope) { + return myRootLocationUrl != null ? super.getLocation(project, searchScope, myRootLocationUrl) + : super.getLocation(project, searchScope); + } + @Override protected AbstractState determineSuiteStateOnFinished() { if (isLeaf() && !isTestsReporterAttached()) { diff --git a/plugins/junit_rt/src/com/intellij/junit4/SMTestSender.java b/plugins/junit_rt/src/com/intellij/junit4/SMTestSender.java index 0544f92d00e6..453a60e6fe7c 100644 --- a/plugins/junit_rt/src/com/intellij/junit4/SMTestSender.java +++ b/plugins/junit_rt/src/com/intellij/junit4/SMTestSender.java @@ -72,7 +72,8 @@ public class SMTestSender extends RunListener { } myPrintStream.println("##teamcity[rootName name = \'" + escapeName(name) + - (comment != null ? ("\' comment = \'" + escapeName(comment)) : "") + + (comment != null ? ("\' comment = \'" + escapeName(comment)) : "") + "\'" + + " location = \'java:suite://" + escapeName(myCurrentClassName) + "\']"); myCurrentClassName = getShortName(myCurrentClassName); } From c7d078a7d324dbf9e796dccb39c690b819561d6e Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Thu, 7 May 2015 14:58:31 +0300 Subject: [PATCH 06/27] Refactored for PY-12621 --- .../testframework/sm/runner/ui/MockPrinter.java | 12 ++++++++++++ .../env/python/testing/PythonPyTestingTest.java | 8 ++++++-- .../com/jetbrains/env/ut/PyUnitTestTask.java | 13 ------------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/MockPrinter.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/MockPrinter.java index 3896d0c64e6d..021798455960 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/MockPrinter.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/MockPrinter.java @@ -29,6 +29,18 @@ public class MockPrinter implements Printer { protected final StringBuilder myStdErr = new StringBuilder(); protected final StringBuilder myStdSys = new StringBuilder(); + /** + * Creates printer and prints printable on it. + * @param printable printable to print on this printer + * @return printer filled with printable output + */ + @NotNull + public static MockPrinter fillPrinter(@NotNull Printable printable) { + MockPrinter printer = new MockPrinter(); + printable.printOn(printer); + return printer; + } + public MockPrinter() { this(true); } diff --git a/python/testSrc/com/jetbrains/env/python/testing/PythonPyTestingTest.java b/python/testSrc/com/jetbrains/env/python/testing/PythonPyTestingTest.java index 6eaf2a872c02..8a0c0ef98697 100644 --- a/python/testSrc/com/jetbrains/env/python/testing/PythonPyTestingTest.java +++ b/python/testSrc/com/jetbrains/env/python/testing/PythonPyTestingTest.java @@ -1,5 +1,6 @@ package com.jetbrains.env.python.testing; +import com.intellij.execution.testframework.sm.runner.ui.MockPrinter; import com.jetbrains.env.PyEnvTestCase; import com.jetbrains.env.ut.PyTestTestTask; import org.hamcrest.Matchers; @@ -29,9 +30,12 @@ public class PythonPyTestingTest extends PyEnvTestCase { assertEquals(9, allTestsCount()); assertEquals(5, passedTestsCount()); assertEquals(4, failedTestsCount()); - Assert.assertThat("No test stdout", getMockPrinter(findTestByName("testOne")).getStdOut(), Matchers.startsWith("I am test1")); + Assert + .assertThat("No test stdout", MockPrinter.fillPrinter(findTestByName("testOne")).getStdOut(), Matchers.startsWith("I am test1")); + // Ensure test has stdout even it fails - Assert.assertThat("No stdout for fail", getMockPrinter(findTestByName("testFail")).getStdOut(), Matchers.startsWith("I will fail")); + Assert.assertThat("No stdout for fail", MockPrinter.fillPrinter(findTestByName("testFail")).getStdOut(), + Matchers.startsWith("I will fail")); } }); } diff --git a/python/testSrc/com/jetbrains/env/ut/PyUnitTestTask.java b/python/testSrc/com/jetbrains/env/ut/PyUnitTestTask.java index e300a1e69255..633885453ff9 100644 --- a/python/testSrc/com/jetbrains/env/ut/PyUnitTestTask.java +++ b/python/testSrc/com/jetbrains/env/ut/PyUnitTestTask.java @@ -274,19 +274,6 @@ public abstract class PyUnitTestTask extends PyExecutionFixtureTestTask { Assert.assertEquals(output(), 0, failedTestsCount()); } - /** - * Creates {@link MockPrinter} filled with test output. Use it to check what output test has. - * - * @param test test to fill mock printer with - * @return filled print. - */ - @NotNull - protected static MockPrinter getMockPrinter(@NotNull final Printable test) { - final MockPrinter printer = new MockPrinter(); - test.printOn(printer); - return printer; - } - /** * Searches for test by its name recursevly in {@link #myTestProxy} * From 08917dd2181f481f55afdafca2a7c4360d413d4c Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Thu, 7 May 2015 15:07:21 +0300 Subject: [PATCH 07/27] more tests for passing arguments (WEB-16470 File watcher: spaces in paths prevent to run program) --- .../execution/GeneralCommandLineTest.java | 104 +++++++++++++++--- .../intellij/execution/ParamPassingTest.java | 8 +- 2 files changed, 88 insertions(+), 24 deletions(-) diff --git a/platform/platform-tests/testSrc/com/intellij/execution/GeneralCommandLineTest.java b/platform/platform-tests/testSrc/com/intellij/execution/GeneralCommandLineTest.java index 64d82f734b59..ffbb6888bfcf 100644 --- a/platform/platform-tests/testSrc/com/intellij/execution/GeneralCommandLineTest.java +++ b/platform/platform-tests/testSrc/com/intellij/execution/GeneralCommandLineTest.java @@ -17,15 +17,18 @@ package com.intellij.execution; import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.execution.util.ExecUtil; +import com.intellij.openapi.application.PathManager; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.Function; +import com.intellij.util.ArrayUtil; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.Test; import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.net.URISyntaxException; import java.net.URL; import java.util.*; @@ -36,6 +39,23 @@ import static org.junit.Assert.*; import static org.junit.Assume.assumeTrue; public class GeneralCommandLineTest { + + private static final String[] ARGUMENTS = { + "with space", + "\"quoted\"", + "\"quoted with spaces\"", + "", + " ", + "param 1", + "\"", + "quote\"inside", + "space \"and \"quotes\" inside", + "\"space \"and \"quotes\" inside\"", + "param2", + "trailing slash\\", + // "two trailing slashes\\\\" /* doesn't work on Windows*/ + }; + @Test public void printCommandLine() { GeneralCommandLine commandLine = new GeneralCommandLine(); @@ -98,20 +118,62 @@ public class GeneralCommandLineTest { } @Test - public void argumentsPassing() throws Exception { - String[] parameters = { - "with space", "\"quoted\"", "\"quoted with spaces\"", "", " ", "param 1", "\"", "param2", "trailing slash\\" - }; - + public void testPassingArgumentsToJavaApp() throws Exception { GeneralCommandLine commandLine = makeJavaCommand(ParamPassingTest.class, null); - commandLine.addParameters(parameters); + String[] args = ArrayUtil.mergeArrays(ARGUMENTS, "&<>()@^|", "\"&<>()@^|\""); + commandLine.addParameters(args); String output = execAndGetOutput(commandLine, null); - assertEquals("=====\n" + StringUtil.join(parameters, new Function() { - @Override - public String fun(String s) { - return ParamPassingTest.format(s); - } - }, "\n") + "\n=====\n", StringUtil.convertLineSeparators(output)); + assertParamPassingTestOutput(output, args); + } + + @Test + public void testPassingArgumentsToJavaAppThroughWinShell() throws Exception { + assumeTrue(SystemInfo.isWindows); + // passing "^" argument doesn't work for cmd.exe + String[] args = ARGUMENTS; + GeneralCommandLine commandLine = makeJavaCommand(ParamPassingTest.class, null); + String oldExePath = commandLine.getExePath(); + commandLine.setExePath("cmd.exe"); + // the test will fails if "call" is omitted + commandLine.getParametersList().prependAll("/D", "/C", "call", oldExePath); + commandLine.addParameters(args); + String output = execAndGetOutput(commandLine, null); + assertParamPassingTestOutput(output, args); + } + + @Test + public void testPassingArgumentsToJavaAppThroughCmdScriptAndWinShell() throws Exception { + assumeTrue(SystemInfo.isWindows); + // passing "^" argument doesn't work for cmd.exe + String[] args = ARGUMENTS; + File cmdScript = createCmdFileLaunchingJavaApp(); + GeneralCommandLine commandLine = new GeneralCommandLine(); + commandLine.setExePath("cmd.exe"); + // the test will fails if "call" is omitted + commandLine.addParameters("/D", "/C", "call", cmdScript.getAbsolutePath()); + commandLine.addParameters(args); + String output = execAndGetOutput(commandLine, null); + assertParamPassingTestOutput(output, args); + } + + @NotNull + private File createCmdFileLaunchingJavaApp() throws Exception { + File cmdScript = FileUtil.createTempFile(new File(PathManager.getTempPath(), "My Program Files" /* path with spaces */), + "my-script", ".cmd", true, true); + GeneralCommandLine commandLine = makeJavaCommand(ParamPassingTest.class, null); + FileUtil.writeToFile(cmdScript, "@" + commandLine.getCommandLineString() + " %*"); + if (!cmdScript.setExecutable(true, true)) { + throw new ExecutionException("Failed to make temp file executable: " + cmdScript); + } + return cmdScript; + } + + private static void assertParamPassingTestOutput(@NotNull String actualOutput, @NotNull String... expectedOutputParameters) { + String content = StringUtil.join(expectedOutputParameters, "\n"); + if (expectedOutputParameters.length > 0) { + content += "\n"; + } + assertEquals(content, StringUtil.convertLineSeparators(actualOutput)); } @Test @@ -250,11 +312,19 @@ public class GeneralCommandLineTest { private static String execAndGetOutput(GeneralCommandLine commandLine, @Nullable String encoding) throws Exception { Process process = commandLine.createProcess(); - byte[] bytes = FileUtil.loadBytes(process.getInputStream()); - String output = encoding != null ? new String(bytes, encoding) : new String(bytes); + String stdOut = loadTextFromStream(process.getInputStream(), encoding); + String stdErr = loadTextFromStream(process.getErrorStream(), encoding); int result = process.waitFor(); - assertEquals("Command:\n" + commandLine.getCommandLineString() + "\nOutput:\n" + output, 0, result); - return output; + assertEquals("Command:\n" + commandLine.getCommandLineString() + + "\nStandard output:\n" + stdOut + + "\nStandard error:\n" + stdErr, + 0, result); + return stdOut; + } + + private static String loadTextFromStream(@NotNull InputStream stream, @Nullable String encoding) throws IOException { + byte[] bytes = FileUtil.loadBytes(stream); + return encoding != null ? new String(bytes, encoding) : new String(bytes); } private GeneralCommandLine makeJavaCommand(Class testClass, @Nullable File copyTo) throws IOException, URISyntaxException { diff --git a/platform/platform-tests/testSrc/com/intellij/execution/ParamPassingTest.java b/platform/platform-tests/testSrc/com/intellij/execution/ParamPassingTest.java index a6fd26fcf9bf..45c283219bd3 100644 --- a/platform/platform-tests/testSrc/com/intellij/execution/ParamPassingTest.java +++ b/platform/platform-tests/testSrc/com/intellij/execution/ParamPassingTest.java @@ -17,14 +17,8 @@ package com.intellij.execution; public class ParamPassingTest { public static void main(String[] args) { - System.out.println("====="); for (String arg : args) { - System.out.println(format(arg)); + System.out.println(arg); } - System.out.println("====="); - } - - public static String format(String arg) { - return String.valueOf(arg.hashCode()); } } From 209f81d4cfb2982e1a71eefd22d5ca1b324e5db4 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 7 May 2015 14:19:17 +0200 Subject: [PATCH 08/27] SplitterTest's superclass changed to ensure that Application is initialized (it's required for ProgressManager.checkCanceled called inside the tests) --- .../com/intellij/spellchecker/inspector/SplitterTest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java b/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java index c9d2d2e7f990..3562a59e2a8f 100644 --- a/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java +++ b/spellchecker/testSrc/com/intellij/spellchecker/inspector/SplitterTest.java @@ -18,9 +18,9 @@ package com.intellij.spellchecker.inspector; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.spellchecker.inspections.*; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import com.intellij.util.Consumer; import junit.framework.Assert; -import junit.framework.TestCase; import org.jetbrains.annotations.NotNull; import java.io.BufferedReader; @@ -32,9 +32,7 @@ import java.util.Arrays; import java.util.List; -public class SplitterTest extends TestCase { - - +public class SplitterTest extends LightPlatformCodeInsightFixtureTestCase { public void testSplitSimpleCamelCase() { String text = "simpleCamelCase"; correctListToCheck(IdentifierSplitter.getInstance(), text, "simple", "Camel", "Case"); From 3bf940be1dc85f12463a0055791a3a29495b5bd9 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Thu, 7 May 2015 15:15:45 +0300 Subject: [PATCH 09/27] IDEA-135540 use extended key code for default key stroke if no modifiers are set --- .../platform-impl/src/com/intellij/ui/KeyStrokeAdapter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/ui/KeyStrokeAdapter.java b/platform/platform-impl/src/com/intellij/ui/KeyStrokeAdapter.java index 6743d619518d..1edd09b443c2 100644 --- a/platform/platform-impl/src/com/intellij/ui/KeyStrokeAdapter.java +++ b/platform/platform-impl/src/com/intellij/ui/KeyStrokeAdapter.java @@ -81,8 +81,9 @@ public class KeyStrokeAdapter implements KeyListener { * @see KeyStroke#getKeyStrokeForEvent(KeyEvent) */ public static KeyStroke getDefaultKeyStroke(KeyEvent event) { + if (event == null || event.isConsumed()) return null; // On Windows and Mac it is preferable to use normal key code here - boolean extendedKeyCodeFirst = !SystemInfo.isWindows && !SystemInfo.isMac; + boolean extendedKeyCodeFirst = !SystemInfo.isWindows && !SystemInfo.isMac && event.getModifiers() == 0; KeyStroke stroke = getKeyStroke(event, extendedKeyCodeFirst); return stroke != null ? stroke : getKeyStroke(event, !extendedKeyCodeFirst); } From 0c8ce9e6a71310a2dd889dd96a1dfdb42ac11563 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Thu, 7 May 2015 16:18:28 +0300 Subject: [PATCH 10/27] IDEA-139883 Changes in file associations are not saved --- .../fileTypes/impl/FileTypeManagerImpl.java | 4 ++-- .../openapi/fileTypes/impl/FileTypesTest.java | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java index 9a35af12118c..82bcff9b52a6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java @@ -91,7 +91,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent "*.hprof;*.pyc;*.pyo;*.rbc;*~;.DS_Store;.bundle;.git;.hg;.svn;CVS;RCS;SCCS;__pycache__;.tox;_svn;rcs;vssver.scc;vssver2.scc;"; private static boolean RE_DETECT_ASYNC = !ApplicationManager.getApplication().isUnitTestMode(); - private final Collection myDefaultTypes = new THashSet(); + private final Set myDefaultTypes = new THashSet(); private final List mySpecialFileTypes = new ArrayList(); private FileTypeAssocTable myPatternsTable = new FileTypeAssocTable(); @@ -1007,7 +1007,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent List notExternalizableFileTypes = new ArrayList(); for (FileType type : mySchemesManager.getAllSchemes()) { - if (!(type instanceof AbstractFileType)) { + if (!(type instanceof AbstractFileType) || myDefaultTypes.contains(type)) { notExternalizableFileTypes.add(type); } } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java index 12ac4f6f267d..4d8c43bb847f 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java @@ -351,7 +351,7 @@ public class FileTypesTest extends PlatformTestCase { } private static void log(String message) { - //System.out.println(message); + System.out.println(message); } private void ensureRedetected(VirtualFile vFile, Set detectorCalled) { @@ -510,4 +510,18 @@ public class FileTypesTest extends PlatformTestCase { fail(JDOMUtil.writeElement(map)); } } + + public void testDefaultFileType() throws Exception { + FileType idl = myFileTypeManager.findFileTypeByName("IDL"); + myFileTypeManager.associatePattern(idl, "*.xxx"); + Element element = myFileTypeManager.getState(); + log(JDOMUtil.writeElement(element)); + myFileTypeManager.removeAssociatedExtension(idl, "xxx"); + myFileTypeManager.clearForTests(); + myFileTypeManager.initStandardFileTypes(); + myFileTypeManager.loadState(element); + myFileTypeManager.initComponent(); + FileType extensions = myFileTypeManager.getFileTypeByExtension("xxx"); + assertEquals("IDL", extensions.getName()); + } } From 36ead80b717c504ee00618de12ba54f043c5a34d Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Thu, 7 May 2015 16:28:45 +0300 Subject: [PATCH 11/27] fix broken test --- .../testSrc/com/intellij/execution/GeneralCommandLineTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/platform-tests/testSrc/com/intellij/execution/GeneralCommandLineTest.java b/platform/platform-tests/testSrc/com/intellij/execution/GeneralCommandLineTest.java index ffbb6888bfcf..9c550db2abe5 100644 --- a/platform/platform-tests/testSrc/com/intellij/execution/GeneralCommandLineTest.java +++ b/platform/platform-tests/testSrc/com/intellij/execution/GeneralCommandLineTest.java @@ -109,8 +109,9 @@ public class GeneralCommandLineTest { File dir = FileUtil.createTempDirectory("path with spaces 'and quotes' и юникодом ", ".tmp"); try { GeneralCommandLine commandLine = makeJavaCommand(ParamPassingTest.class, dir); + commandLine.addParameter("test"); String output = execAndGetOutput(commandLine, null); - assertEquals("=====\n=====\n", StringUtil.convertLineSeparators(output)); + assertEquals("test\n", StringUtil.convertLineSeparators(output)); } finally { FileUtil.delete(dir); From 350226a6ced93567f312c0ca86239fbda65183c6 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 7 May 2015 15:43:52 +0200 Subject: [PATCH 12/27] fix testdata --- .../junit/JUnitTreeByDescriptionHierarchyTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java b/plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java index 85d9482e0fb1..09af7f023798 100644 --- a/plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java +++ b/plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java @@ -64,7 +64,7 @@ public class JUnitTreeByDescriptionHierarchyTest { "##teamcity[enteredTheMatrix]\n" + - "##teamcity[rootName name = 'root']\n" + + "##teamcity[rootName name = 'root' location = 'java:suite://root']\n" + "##teamcity[testSuiteFinished name='root']\n" + "##teamcity[testSuiteStarted name ='TestA']\n" + "##teamcity[testSuiteStarted name ='|[0|]']\n" + @@ -108,7 +108,7 @@ public class JUnitTreeByDescriptionHierarchyTest { "##teamcity[suiteTreeEnded name='|[1|]']\n", //start "##teamcity[enteredTheMatrix]\n" + - "##teamcity[rootName name = 'TestA' comment = 'a']\n" + + "##teamcity[rootName name = 'TestA' comment = 'a' location = 'java:suite://a.TestA']\n" + "##teamcity[testSuiteStarted name ='|[0|]']\n" + "##teamcity[testStarted name='testName|[0|]' locationHint='java:test://a.TestA.testName|[0|]']\n" + "\n" + @@ -153,7 +153,7 @@ public class JUnitTreeByDescriptionHierarchyTest { //started "##teamcity[enteredTheMatrix]\n" + - "##teamcity[rootName name = 'root']\n" + + "##teamcity[rootName name = 'root' location = 'java:suite://root']\n" + "##teamcity[testSuiteFinished name='root']\n" + "##teamcity[testSuiteStarted name ='ASuite1']\n" + "##teamcity[testSuiteStarted name ='ATest']\n" + @@ -232,7 +232,7 @@ public class JUnitTreeByDescriptionHierarchyTest { //start "##teamcity[enteredTheMatrix]\n" + - "##teamcity[rootName name = 'root']\n" + + "##teamcity[rootName name = 'root' location = 'java:suite://root']\n" + "##teamcity[testSuiteFinished name='root']\n" + "##teamcity[testSuiteStarted name ='ATest']\n" + "##teamcity[testSuiteStarted name ='|[0|]']\n" + @@ -288,7 +288,7 @@ public class JUnitTreeByDescriptionHierarchyTest { "##teamcity[enteredTheMatrix]\n" + - "##teamcity[rootName name = 'TestA']\n" + + "##teamcity[rootName name = 'TestA' location = 'java:suite://TestA']\n" + "##teamcity[testStarted name='warning' locationHint='java:test://junit.framework.TestSuite$1.warning']\n" + "\n" + "##teamcity[testFinished name='warning']\n" + From 676ab3363ab3d3681ad12919a7ba74c62f79b9b9 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Thu, 7 May 2015 16:12:47 +0200 Subject: [PATCH 13/27] rollback warning attributes --- .../src/DefaultColorSchemesManager.xml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/platform/platform-resources/src/DefaultColorSchemesManager.xml b/platform/platform-resources/src/DefaultColorSchemesManager.xml index 84b4538bdbdf..cec4d4fcb8b6 100644 --- a/platform/platform-resources/src/DefaultColorSchemesManager.xml +++ b/platform/platform-resources/src/DefaultColorSchemesManager.xml @@ -306,9 +306,11 @@