mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
diag: fold by default the DEBUG logging of the failed tests
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.
|
||||
*/
|
||||
package com.intellij.testFramework;
|
||||
|
||||
import com.intellij.execution.ConsoleFolding;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FailedTestDebugLogConsoleFolding extends ConsoleFolding {
|
||||
@Override
|
||||
public boolean shouldFoldLine(String line) {
|
||||
return line.indexOf(TestLoggerFactory.FAILED_TEST_DEBUG_OUTPUT_MARKER) != -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlaceholderText(List<String> lines) {
|
||||
return " <Failed tests DEBUG log>";
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.LineTokenizer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.apache.log4j.*;
|
||||
import org.apache.log4j.spi.LoggingEvent;
|
||||
@@ -145,6 +146,8 @@ public class TestLoggerFactory implements Logger.Factory {
|
||||
|
||||
private static final StringWriter STRING_WRITER = new StringWriter();
|
||||
private static final StringBuffer BUFFER = STRING_WRITER.getBuffer();
|
||||
static final char FAILED_TEST_DEBUG_OUTPUT_MARKER = '\u2003';
|
||||
// inserted unicode whitespace to be able to tell these failed tests log lines from the others and fold them
|
||||
private static final WriterAppender APPENDER = new WriterAppender(new PatternLayout("%d{HH:mm:ss,SSS} %p %.30c - %m%n"), STRING_WRITER);
|
||||
private static final int MAX_BUFFER_LENGTH = 100000;
|
||||
private static final String CFQN = Category.class.getName();
|
||||
@@ -165,8 +168,20 @@ public class TestLoggerFactory implements Logger.Factory {
|
||||
}
|
||||
|
||||
public static void onTestFinished(boolean success) {
|
||||
if (!success) {
|
||||
System.err.println(BUFFER);
|
||||
if (!success && BUFFER.length() != 0) {
|
||||
if (UsefulTestCase.IS_UNDER_TEAMCITY) {
|
||||
// print in one statement to avoid exception text cutting in between causing this fold to expand
|
||||
BUFFER.insert(0, "##teamcity[blockOpened name='DEBUG log']\n");
|
||||
BUFFER.append( "\n##teamcity[blockClosed name='DEBUG log']\n");
|
||||
System.err.println(BUFFER);
|
||||
}
|
||||
else {
|
||||
// mark each line in IDEA console with this hidden mark to be able to fold it automatically
|
||||
String[] lines = LineTokenizer.tokenize(BUFFER, false, false);
|
||||
String text = StringUtil.join(lines, FAILED_TEST_DEBUG_OUTPUT_MARKER + "\n");
|
||||
if (!text.startsWith("\n")) text = "\n" + text;
|
||||
System.err.println(text);
|
||||
}
|
||||
}
|
||||
BUFFER.setLength(0);
|
||||
}
|
||||
|
||||
@@ -1244,6 +1244,7 @@
|
||||
<stacktrace.fold substring="at sun.rmi."/>
|
||||
<stacktrace.fold substring="at com.sun.proxy.$Proxy"/>
|
||||
<stacktrace.fold substring="at com.intellij.rt.execution."/>
|
||||
<console.folding implementation="com.intellij.testFramework.FailedTestDebugLogConsoleFolding"/>
|
||||
|
||||
<debuggerEditorTextProvider language="JAVA" implementationClass="com.intellij.debugger.impl.JavaEditorTextProviderImpl"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user