Convert tcServiceMessages library to maven (IDEA-220225)

GitOrigin-RevId: 6673dcae49008a735f8d28b921167f68bd4056ad
This commit is contained in:
Alexander Zolotov
2019-08-30 18:17:36 +03:00
committed by intellij-monorepo-bot
parent bd98f5872b
commit 14512d293d
7 changed files with 53 additions and 56 deletions

View File

@@ -56,5 +56,10 @@
<option name="name" value="e585af2a-f558-424b-a8e6-3a1365d5b046" />
<option name="url" value="https://cache-redirector.jetbrains.com/jetbrains.bintray.com/markdown" />
</remote-repository>
<remote-repository>
<option name="id" value="36870030-7a21-4052-b93a-010aa4c33366" />
<option name="name" value="36870030-7a21-4052-b93a-010aa4c33366" />
<option name="url" value="https://cache-redirector.jetbrains.com/download.jetbrains.com/teamcity-repository" />
</remote-repository>
</component>
</project>

View File

@@ -1,11 +1,12 @@
<component name="libraryTable">
<library name="tcServiceMessages">
<library name="tcServiceMessages" type="repository">
<properties include-transitive-deps="false" maven-id="org.jetbrains.teamcity:serviceMessages:2019.1.4-SNAPSHOT" />
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/serviceMessages.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/teamcity/serviceMessages/2019.1.4-SNAPSHOT/serviceMessages-2019.1.4-SNAPSHOT.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/lib/src/serviceMessages_279xxx_src.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/teamcity/serviceMessages/2019.1.4-SNAPSHOT/serviceMessages-2019.1.4-SNAPSHOT-sources.jar!/" />
</SOURCES>
</library>
</component>

Binary file not shown.

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework.sm.runner;
import com.intellij.execution.process.ColoredOutputTypeRegistry;
@@ -8,6 +8,7 @@ import com.intellij.execution.testframework.sm.runner.events.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import jetbrains.buildServer.messages.serviceMessages.*;
import org.jetbrains.annotations.ApiStatus;
@@ -33,6 +34,7 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer
private final MyServiceMessageVisitor myServiceMessageVisitor;
private final String myTestFrameworkName;
private final boolean myValidateServiceMessagesAttributes;
private final OutputEventSplitter mySplitter;
private volatile GeneralTestEventsProcessor myProcessor;
@@ -40,31 +42,26 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer
private boolean myFirstTestingStartedEvent = true;
public OutputToGeneralTestEventsConverter(@NotNull final String testFrameworkName,
@NotNull final TestConsoleProperties consoleProperties) {
public OutputToGeneralTestEventsConverter(@NotNull final String testFrameworkName, @NotNull final TestConsoleProperties consoleProperties) {
// If console is editable, user may want to see output before new line char.
// stdout: "enter your name:"
// There is no new line after it, but user still wants to see this message.
// So, if console is editable, we enable "doNotBufferTextUntilNewLine".
this(testFrameworkName, consoleProperties.isEditable(), consoleProperties.tcMessageHasNewLinePrefix());
this(testFrameworkName, consoleProperties.isEditable(), consoleProperties.tcMessageHasNewLinePrefix(),
!(consoleProperties instanceof SMTRunnerConsoleProperties) || !((SMTRunnerConsoleProperties)consoleProperties).isIdBasedTestTree());
}
/**
* @see OutputToGeneralTestEventsConverter#OutputToGeneralTestEventsConverter(String, boolean, boolean)
*/
public OutputToGeneralTestEventsConverter(@NotNull final String testFrameworkName,
final boolean doNotBufferTextUntilNewLine) {
this(testFrameworkName, doNotBufferTextUntilNewLine, false);
}
/**
* @param cutNewLineBeforeServiceMessage see {@link OutputEventSplitter} constructor
* @param doNotBufferTextUntilNewLine opposite to {@link OutputEventSplitter} constructor
* @param cutNewLineBeforeServiceMessage see {@link OutputEventSplitter} constructor
* @param validateServiceMessagesAttributes whether ParseException should happen if message doesn't contain required attributes. see {@link ServiceMessagesParser#setValidateRequiredAttributes(boolean)}
*/
public OutputToGeneralTestEventsConverter(@NotNull final String testFrameworkName,
final boolean doNotBufferTextUntilNewLine,
final boolean cutNewLineBeforeServiceMessage) {
boolean doNotBufferTextUntilNewLine,
boolean cutNewLineBeforeServiceMessage,
boolean validateServiceMessagesAttributes) {
myTestFrameworkName = testFrameworkName;
myValidateServiceMessagesAttributes = validateServiceMessagesAttributes;
myServiceMessageVisitor = new MyServiceMessageVisitor();
mySplitter = new OutputEventSplitter(!doNotBufferTextUntilNewLine, cutNewLineBeforeServiceMessage) {
@Override
@@ -127,19 +124,32 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer
protected boolean processServiceMessages(final String text,
final Key outputType,
final ServiceMessageVisitor visitor) throws ParseException {
// service message parser expects line like "##teamcity[ .... ]" without whitespaces in the end.
final ServiceMessage message;
try {
message = ServiceMessage.parse(text.trim());
}
catch (ParseException e) {
LOG.error("Failed to parse service message", e, text);
String trimmedText = text.trim();
if (!trimmedText.startsWith(ServiceMessage.SERVICE_MESSAGE_START) || !trimmedText.endsWith(ServiceMessage.SERVICE_MESSAGE_END)) {
return false;
}
if (message != null) {
message.visit(visitor);
}
return message != null;
Ref<Boolean> success = Ref.create(false);
ServiceMessagesParser parser = new ServiceMessagesParser();
parser.setValidateRequiredAttributes(myValidateServiceMessagesAttributes);
parser.parse(trimmedText, new ServiceMessageParserCallback() {
@Override
public void regularText(@NotNull String text1) {
}
@Override
public void serviceMessage(@NotNull ServiceMessage message) {
message.visit(visitor);
success.set(true);
}
@Override
public void parseException(@NotNull ParseException parseException, @NotNull String text1) {
LOG.error("Failed to parse service message", parseException, text1);
success.set(false);
}
});
return success.get();
}

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework.sm.runner;
import com.intellij.execution.executors.DefaultRunExecutor;
@@ -43,12 +29,8 @@ public class SMTRunnerIntegrationTest extends LightPlatformTestCase {
super.setUp();
SMTRunnerConsoleProperties properties = new SMTRunnerConsoleProperties(new MockRuntimeConfiguration(getProject()),
TEST_FRAMEWORK_NAME,
DefaultRunExecutor.getRunExecutorInstance()) {
@Override
public boolean isIdBasedTestTree() {
return true;
}
};
DefaultRunExecutor.getRunExecutorInstance());
properties.setIdBasedTestTree(true);
myConsole = (SMTRunnerConsoleView)SMTestRunnerConnectionUtil.createConsole(TEST_FRAMEWORK_NAME, properties);
myResultsViewer = myConsole.getResultsViewer();
myRootNode = myResultsViewer.getTestsRootNode();
@@ -71,7 +53,7 @@ public class SMTRunnerIntegrationTest extends LightPlatformTestCase {
}
}
public void multiTestings() {
public void testMultiTestings() {
notifyStdoutLineAvailable("##teamcity[enteredTheMatrix]");
notifyStdoutLineAvailable("##teamcity[testingStarted]");
assertState(0, 0, 0, ColorProgressBar.GREEN);
@@ -87,7 +69,7 @@ public class SMTRunnerIntegrationTest extends LightPlatformTestCase {
assertState(0, 0, 0, ColorProgressBar.GREEN);
}
public void failedThenSuccessTestings() {
public void testFailedThenSuccessTestings() {
notifyStdoutLineAvailable("##teamcity[enteredTheMatrix]");
notifyStdoutLineAvailable("##teamcity[testingStarted]");
notifyStdoutLineAvailable("##teamcity[testSuiteStarted nodeId='1' parentNodeId='0' name='sum-test.js']");

View File

@@ -3,12 +3,11 @@ package com.intellij.execution.testframework.sm.runner
import com.intellij.execution.process.ProcessOutputTypes
import com.intellij.execution.testframework.sm.ServiceMessageBuilder
import com.intellij.testFramework.LightPlatformTestCase
import org.junit.Assert
class StdoutToSMTreeTest : BaseSMTRunnerTestCase() {
private val converter: OutputToGeneralTestEventsConverter by lazy { OutputToGeneralTestEventsConverter("MyTest", false) }
private val converter: OutputToGeneralTestEventsConverter by lazy { OutputToGeneralTestEventsConverter("MyTest", false, false, true) }
private var flushBufferSize = 0
@@ -47,10 +46,10 @@ class StdoutToSMTreeTest : BaseSMTRunnerTestCase() {
this.flushBufferSize = flushBufferSize
val testProxy = SMTestProxy.SMRootTestProxy()
converter.processor = if (idBased) {
GeneralIdBasedToSMTRunnerEventsConvertor(getProject(), testProxy, "root")
GeneralIdBasedToSMTRunnerEventsConvertor(project, testProxy, "root")
}
else {
GeneralToSMTRunnerEventsConvertor(getProject(), testProxy, "root")
GeneralToSMTRunnerEventsConvertor(project, testProxy, "root")
}
converter.setTestingStartedHandler { }