Skip to content

Commit 1cef9ce

Browse files
authored
Merge pull request #155 from TonioGela/better-test-reporting
Better test failure reporting
2 parents 7a95cbe + 184e3a3 commit 1cef9ce

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

tests/shared/src/test/scala/org/typelevel/toolkit/ScalaCliProcess.scala

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.typelevel.toolkit
1818

1919
import cats.effect.kernel.Resource
20-
import cats.effect.std.Console
2120
import cats.effect.IO
2221
import cats.syntax.parallel._
2322
import buildinfo.BuildInfo
@@ -43,9 +42,17 @@ object ScalaCliProcess {
4342
).parFlatMapN {
4443
case (0, _, _) => IO.unit
4544
case (exitCode, stdout, stdErr) =>
46-
IO.println(stdout) >> Console[IO].errorln(stdErr) >> IO.delay(
47-
fail(s"Non zero exit code ($exitCode) for ${args.mkString(" ")}")
48-
)
45+
val errorMessage: String = List(
46+
Option(stdout).filter(_.nonEmpty).map(s => s"[STDOUT]: $s"),
47+
Option(stdErr).filter(_.nonEmpty).map(s => s"[STDERR]: $s")
48+
).foldLeft(
49+
s"Non zero exit code ($exitCode) for ${args.mkString(" ")}"
50+
) {
51+
case (summary, Some(err)) => s"$err\n$summary"
52+
case (summary, None) => summary
53+
}
54+
55+
IO.delay(fail(errorMessage))
4956
}
5057
)
5158

0 commit comments

Comments
 (0)