Revert "FlakyTestLogger for debugging the SpringIntentionsTest"

because it is no mo necessary, tests were fixed in 3ed4fbf7f0609825de13c77ee4d0fec151c0cc3e

This reverts commit d9e4cd35e5dc70beb146b6f566a6300df4fc1ac7.
This reverts commit 1130715be3508cbaab8579dbbc8193e5713dfa9d.

GitOrigin-RevId: fb61c983ed5fa84cd7658e47d875aa6d1ad26e75
This commit is contained in:
Nicolay Mitropolsky
2021-08-02 19:01:59 +00:00
committed by intellij-monorepo-bot
parent 23c73eeec6
commit d5b939b7be
3 changed files with 1 additions and 80 deletions
@@ -1,63 +0,0 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.testFramework
import com.intellij.concurrency.ConcurrentCollectionFactory
import com.intellij.openapi.Disposable
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.Key
import org.jetbrains.annotations.TestOnly
import java.io.PrintWriter
import java.io.StringWriter
@Deprecated("this class is here only for debugging a flaky test, it will be deleted as soon problem will be resolved")
class FlakyTestLogger(val enabled: Boolean) : Disposable {
data class Entry(val time: Long, val text: String)
private val lists = ConcurrentCollectionFactory.createConcurrentIdentitySet<List<Entry>>()
private val lines = ThreadLocal.withInitial { ArrayList<Entry>().also { lists.add(it) } }
private fun add(str: String) {
lines.get().add(Entry(System.currentTimeMillis(), """${System.currentTimeMillis()} ${Thread.currentThread().name} $str"""))
}
override fun dispose() {
lists.flatten().sortedBy { it.time }.forEach { println(it.text) }
}
fun append(line: String) {
if (!enabled) return
add(line)
}
fun append(exception: Exception) {
if (!enabled) return
val stringWriter = StringWriter()
exception.printStackTrace(PrintWriter(stringWriter))
add(stringWriter.toString())
}
companion object {
private val KEY = Key.create<FlakyTestLogger>("LogAccumulator")
@JvmStatic
fun get(): FlakyTestLogger? = TestModeFlags.get(KEY)
@JvmStatic
fun force(): FlakyTestLogger = get() ?: FlakyTestLogger(false)
@JvmStatic
fun isEnabled(): Boolean = TestModeFlags.get(KEY) != null
@JvmStatic
@TestOnly
fun enable(disposer: Disposable) {
TestModeFlags.set(KEY, FlakyTestLogger(true).also { Disposer.register(disposer, it) }, disposer)
}
}
}
@@ -20,7 +20,6 @@ import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlElement;
import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
import com.intellij.testFramework.FlakyTestLogger;
import com.intellij.util.*;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.xml.*;
@@ -656,17 +655,7 @@ public abstract class DomInvocationHandler extends UserDataHolderBase implements
@Nullable
public final Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
try {
Invocation invocation = findInvocation(method);
Object r = invocation.invoke(this, args);
FlakyTestLogger log = FlakyTestLogger.get();
if (log != null && method.getName().equals("exists")) {
log.append("Invocation: for '" + method + "' is '" + invocation + " of " + invocation.getClass() + "' handler = '" + this +
" of " + this.getClass() + "' r = " + r + " of " + ObjectUtils.doIfNotNull(r, Object::getClass));
if (this instanceof IndexedElementInvocationHandler) {
log.append(((IndexedElementInvocationHandler)this).created);
}
}
return r;
return findInvocation(method).invoke(this, args);
}
catch (InvocationTargetException ex) {
throw ex.getTargetException();
@@ -20,7 +20,6 @@ import com.intellij.openapi.util.Factory;
import com.intellij.psi.xml.XmlElement;
import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
import com.intellij.testFramework.FlakyTestLogger;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.xml.DomElement;
import com.intellij.util.xml.EvaluatedXmlName;
@@ -39,8 +38,6 @@ public class IndexedElementInvocationHandler extends DomInvocationHandler {
private static final Logger LOG = Logger.getInstance(IndexedElementInvocationHandler.class);
private final int myIndex;
public final Exception created;
public IndexedElementInvocationHandler(final EvaluatedXmlName tagName,
final FixedChildDescriptionImpl description,
final int index,
@@ -48,8 +45,6 @@ public class IndexedElementInvocationHandler extends DomInvocationHandler {
final DomManagerImpl manager,
@Nullable ElementStub stub) {
super(description.getType(), strategy, tagName, description, manager, strategy.isPhysical(), stub);
created = FlakyTestLogger.isEnabled() ? new Exception(
"IndexedElementInvocationHandler(" + tagName + ", " + description + ", " + strategy + ", " + index + ", " + stub + ")") : null;
myIndex = index;
}