From 46aa85a55fec1bb525ad2e66e4dfc67d79ca67df Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 24 Nov 2015 11:01:40 +0100 Subject: [PATCH] tests: propagate critical error marks instead of recalculating for children (IDEA-148322) --- .../testframework/sm/runner/SMTestProxy.java | 40 ++++++------------- 1 file changed, 13 insertions(+), 27 deletions(-) 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 9f6be1e6f844..9009272f4e03 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 @@ -66,7 +66,6 @@ public class SMTestProxy extends AbstractTestProxy { private Long myDuration = null; // duration is unknown private boolean myDurationIsCached = false; // is used for separating unknown and unset duration private boolean myHasCriticalErrors = false; - private boolean myHasErrorsCached = false; private boolean myHasPassedTests = false; private boolean myHasPassedTestsCached = false; @@ -144,32 +143,7 @@ public class SMTestProxy extends AbstractTestProxy { } public boolean hasErrors() { - // if already cached - if (myHasErrorsCached) { - return myHasCriticalErrors; - } - - final boolean canCacheErrors = !myState.isInProgress(); - // calculate - final boolean hasErrors = calcHasErrors(); - if (canCacheErrors || hasErrors) { - myHasCriticalErrors = hasErrors; - myHasErrorsCached = true; - } - return hasErrors; - } - - private boolean calcHasErrors() { - if (myHasCriticalErrors) { - return true; - } - - for (SMTestProxy child : getChildren()) { - if (child.hasErrors()) { - return true; - } - } - return false; + return myHasCriticalErrors; } /** @@ -608,6 +582,9 @@ public class SMTestProxy extends AbstractTestProxy { public void addError(final String output, @Nullable final String stackTrace, boolean isCritical) { myHasCriticalErrors = isCritical; + if (isCritical) { + invalidateCachedHasErrorMark(); + } setStacktraceIfNotSet(stackTrace); addLast(new Printable() { @@ -619,6 +596,15 @@ public class SMTestProxy extends AbstractTestProxy { }); } + private void invalidateCachedHasErrorMark() { + myHasCriticalErrors = true; + // Invalidates hasError state of container suite + final SMTestProxy containerSuite = getParent(); + if (containerSuite != null && !containerSuite.hasErrors()) { + containerSuite.invalidateCachedHasErrorMark(); + } + } + public void addSystemOutput(final String output) { addLast(new Printable() { public void printOn(final Printer printer) {