Skip to content

Commit

Permalink
Add hanging test for the known case
Browse files Browse the repository at this point in the history
  • Loading branch information
kubukoz committed Jan 24, 2024
1 parent 4d67188 commit cf58e59
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
25 changes: 24 additions & 1 deletion modules/framework/cats/test/src/DogFoodTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,29 @@ object DogFoodTests extends IOSuite {
}
}

// https://github.com/disneystreaming/weaver-test/issues/724
test("test suite outputs stack traces even if the output is very long") {
_.runSuite(Meta.ErroringWithLongPayload).map {
case (logs, _) =>
val actual = extractLogEventAfterFailures(logs) {
case LoggedEvent.Error(msg) => msg
}.get

val expected =
s"""
|- erroring with a long message: ${Meta.ErroringWithLongPayload.smiles} 0ms
| Meta$$CustomException: surfaced error
|
| DogFoodTests.scala:15 my.package.MyClass#MyMethod
| DogFoodTests.scala:20 my.package.ClassOfDifferentLength#method$$new$$1
| <snipped> cats.effect.internals.<...>
| <snipped> java.util.concurrent.<...>
|""".stripMargin.trim

expect.same(actual, expected)
}
}

test("test suite outputs stack traces of exception causes") {
_.runSuite(Meta.ErroringWithCauses).map {
case (logs, _) =>
Expand Down Expand Up @@ -208,7 +231,7 @@ object DogFoodTests extends IOSuite {
}

test(
"expect.same delegates to show when an insteance is found") {
"expect.same delegates to show when an instance is found") {
_.runSuite(Meta.Rendering).map {
case (logs, _) =>
val actual =
Expand Down
16 changes: 16 additions & 0 deletions modules/framework/cats/test/src/Meta.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,22 @@ object Meta {
}
}

object ErroringWithLongPayload extends SimpleIOSuite {
override implicit protected def effectCompat: UnsafeRun[IO] =
SetTimeUnsafeRun

val smiles = ":)" * 1024

test("erroring with a long message: " + smiles) {
IO.raiseError(
CustomException(
"surfaced error",
withSnips = true
)
).as(success)
}
}

case class CustomException(
str: String,
causedBy: Exception = null,
Expand Down

0 comments on commit cf58e59

Please sign in to comment.