Merge branch 'master' of git.labs.intellij.net:idea/community

This commit is contained in:
Bas Leijdekkers
2011-03-25 14:07:47 +01:00
6 changed files with 48 additions and 11 deletions
@@ -17,6 +17,7 @@ package com.intellij.codeInsight.unwrap;
import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.tree.java.PsiWhileStatementImpl;
import com.intellij.util.IncorrectOperationException;
public class JavaWhileUnwrapper extends JavaUnwrapper {
@@ -25,7 +26,9 @@ public class JavaWhileUnwrapper extends JavaUnwrapper {
}
public boolean isApplicableTo(PsiElement e) {
return e instanceof PsiWhileStatement || e instanceof PsiDoWhileStatement;
return e instanceof PsiWhileStatementImpl // Don't use "e instanceof PsiWhileStatement" because JspWhileStatement intanceof PsiWhileStatement,
// but we doesn't support unwrap JspWhileStatement.
|| e instanceof PsiDoWhileStatement;
}
@Override
@@ -15,13 +15,16 @@
*/
package com.intellij.execution.testframework.sm;
import com.intellij.execution.testframework.TestConsoleProperties;
import com.intellij.execution.testframework.sm.runner.OutputToGeneralTestEventsConverter;
import org.jetbrains.annotations.NotNull;
/**
* @author gregsh
*/
public interface SMCustomMessagesParsing {
OutputToGeneralTestEventsConverter createTestEventsConverter(final String testFrameworkName);
OutputToGeneralTestEventsConverter createTestEventsConverter(@NotNull final String testFrameworkName,
@NotNull final TestConsoleProperties consoleProperties);
}
@@ -179,8 +179,8 @@ public class SMTestRunnerConnectionUtil {
@NotNull final String testFrameworkName) {
//build messages consumer
final OutputToGeneralTestEventsConverter outputConsumer = consoleProperties instanceof SMCustomMessagesParsing
? ((SMCustomMessagesParsing)consoleProperties).createTestEventsConverter(testFrameworkName)
: new OutputToGeneralTestEventsConverter(testFrameworkName);
? ((SMCustomMessagesParsing)consoleProperties).createTestEventsConverter(testFrameworkName, consoleProperties)
: new OutputToGeneralTestEventsConverter(testFrameworkName, consoleProperties);
//events processor
final GeneralToSMTRunnerEventsConvertor eventsProcessor = new GeneralToSMTRunnerEventsConvertor(resultsViewer.getTestsRootNode(),
@@ -16,6 +16,7 @@
package com.intellij.execution.testframework.sm.runner;
import com.intellij.execution.process.ProcessOutputTypes;
import com.intellij.execution.testframework.TestConsoleProperties;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.text.StringUtil;
@@ -41,10 +42,13 @@ import static com.intellij.execution.testframework.sm.runner.GeneralToSMTRunnerE
*/
public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer {
private static final Logger LOG = Logger.getInstance(OutputToGeneralTestEventsConverter.class.getName());
private static final String TEAMCITY_SERVICE_MESSAGE_PREFIX = "##teamcity[";
private GeneralTestEventsProcessor myProcessor;
private final MyServiceMessageVisitor myServiceMessageVisitor;
private final String myTestFrameworkName;
private boolean myStdinSupportEnabled;
private static class OutputChunk {
private final Key myKey;
@@ -70,10 +74,12 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer
private final List<OutputChunk> myOutputChunks;
public OutputToGeneralTestEventsConverter(@NotNull final String testFrameworkName) {
public OutputToGeneralTestEventsConverter(@NotNull final String testFrameworkName,
@NotNull final TestConsoleProperties consoleProperties) {
myTestFrameworkName = testFrameworkName;
myServiceMessageVisitor = new MyServiceMessageVisitor();
myOutputChunks = new ArrayList<OutputChunk>();
myStdinSupportEnabled = consoleProperties.isEditable();
}
public void setProcessor(final GeneralTestEventsProcessor processor) {
@@ -145,9 +151,28 @@ public class OutputToGeneralTestEventsConverter implements ProcessOutputConsumer
if (lastChar == '\n' || lastChar == '\r') {
// buffer contains consistent string
flushStdOutputBuffer();
} else {
// test framework may show some promt and ask user for smth. Question may not
// finish with \n or \r thus buffer wont be flushed and user will have to input smth
// before question. And question will became visible with next portion of text.
// Such behaviour is confusing. So
// 1. Let's assume that sevice messages starts with \n if console is editable
// 2. Then we can suggest that each service message will start from new line and buffer should
// be flushed before every service message. Thus if chunks list is empty and output doesn't end
// with \n or \r but starts with ##teamcity then it is a service message and should be buffered otherwise
// we can safely flush buffer.
// TODO if editable:
if (myStdinSupportEnabled && !isMostLikelyServiceMessagePart(text)) {
flushStdOutputBuffer();
}
}
}
protected boolean isMostLikelyServiceMessagePart(@NotNull final String text) {
return text.startsWith(TEAMCITY_SERVICE_MESSAGE_PREFIX);
}
private void processConsistentText(final String text, final Key outputType, boolean tcLikeFakeOutput) {
try {
final ServiceMessage serviceMessage = parseServiceMessage(text, outputType);
@@ -20,6 +20,7 @@ import com.intellij.execution.configurations.RuntimeConfiguration;
import com.intellij.execution.testframework.TestConsoleProperties;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.util.config.Storage;
import org.jetbrains.annotations.NotNull;
/**
* @author: Roman Chernyatchik
@@ -32,11 +33,12 @@ public class SMTRunnerConsoleProperties extends TestConsoleProperties {
* @param testFrameworkName Prefix for storage which keeps runner settings. E.g. "RubyTestUnit"
* @param executor
*/
public SMTRunnerConsoleProperties(final RuntimeConfiguration config,
final String testFrameworkName,
Executor executor)
public SMTRunnerConsoleProperties(@NotNull final RuntimeConfiguration config,
@NotNull final String testFrameworkName,
@NotNull final Executor executor)
{
super(new Storage.PropertiesComponentStorage(testFrameworkName + "Support.", PropertiesComponent.getInstance()), config.getProject(),
super(new Storage.PropertiesComponentStorage(testFrameworkName + "Support.", PropertiesComponent.getInstance()),
config.getProject(),
executor);
myConfiguration = config;
}
@@ -136,10 +136,14 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp
* Allows to make console editable and disable/enable input sending in process stdin stream.
* Normally tests shouldn't ask anything in stdin so console is view only by default.
*
* NB: Process input support feature isn't fully implemented. Input text will be lost after
* NB1: Process input support feature isn't fully implemented. Input text will be lost after
* switching to any other test/suite in tests results view. It's highly not recommended to change
* default behaviour. Please do it only in critical cases and only if you are sure that you need this feature.
*
*
* NB2: If you are using Service Messages based test runner please ensure that before each service message
* (e.g. #teamcity[...]) you always send "\n" to the output stream.
*
* @return False for view-only mode and true for stdin support.
*/
public boolean isEditable() {