Skip to content

Commit c3f9f5a

Browse files
authored
Reduce the stack trace output in tests (#13088)
- followup #13044 Changelog: - update: move the logic that prints stack traces to a separate `DebugSuite` to reduce the test output
1 parent 7776c6d commit c3f9f5a

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

engine/runtime-integration-tests/src/test/scala/org/enso/interpreter/test/instrument/RuntimeAsyncCommandsTest.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import org.enso.polyglot.runtime.Runtime.Api.{
1414
import org.enso.runtime.utils.ThreadUtils
1515
import org.enso.text.{ContentVersion, Sha3_224VersionCalculator}
1616
import org.enso.text.editing.model
17-
import org.enso.testkit.FlakySpec
17+
import org.enso.testkit.{DebugSpec, FlakySpec}
1818
import org.graalvm.polyglot.Context
1919
import org.scalatest.BeforeAndAfterEach
2020
import org.scalatest.flatspec.AnyFlatSpec
@@ -30,6 +30,7 @@ class RuntimeAsyncCommandsTest
3030
extends AnyFlatSpec
3131
with Matchers
3232
with BeforeAndAfterEach
33+
with DebugSpec
3334
with FlakySpec {
3435

3536
// === Test Utilities =======================================================
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.enso.testkit
2+
3+
import org.enso.runtime.utils.ThreadUtils
4+
import org.scalatest._
5+
6+
/** Trait provides debug information when a test fails in the suite. */
7+
trait DebugSpec extends TestSuite {
8+
9+
override def withFixture(test: NoArgTest): Outcome = {
10+
val result = super.withFixture(test)
11+
12+
if (result.isFailed || result.isCanceled) {
13+
val msg = ThreadUtils.dumpAllStacktraces(
14+
s"Thread dump of the failed test `${test.name}`"
15+
)
16+
println(msg)
17+
}
18+
19+
result
20+
}
21+
}

lib/scala/testkit/src/main/scala/org/enso/testkit/FlakySpec.scala

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.enso.testkit
22

3-
import org.enso.runtime.utils.ThreadUtils
43
import org.scalatest._
54

65
/** Trait is used to mark the tests in the suite as _flaky_ and make them
@@ -21,16 +20,7 @@ trait FlakySpec extends TestSuite {
2120
object SkipOnFailure extends Tag("org.enso.test.skiponfailure")
2221

2322
override def withFixture(test: NoArgTest): Outcome = {
24-
val result = super.withFixture(test)
25-
26-
if (result.isFailed || result.isCanceled) {
27-
val msg = ThreadUtils.dumpAllStacktraces(
28-
s"Thread dump of the failed flaky test `${test.name}`"
29-
)
30-
println(msg)
31-
}
32-
33-
result match {
23+
super.withFixture(test) match {
3424
case Failed(_) | Canceled(_)
3525
if Flaky.isEnabled && test.tags.contains(Flaky.name) =>
3626
Pending

0 commit comments

Comments
 (0)