|
16 | 16 |
|
17 | 17 | package org.typelevel.toolkit |
18 | 18 |
|
19 | | -import munit.{CatsEffectSuite, TestOptions} |
| 19 | +import cats.effect.IO |
20 | 20 | import buildinfo.BuildInfo.scala3 |
21 | | -import scala.concurrent.duration._ |
| 21 | +import weaver.* |
| 22 | +import scala.concurrent.duration.* |
22 | 23 |
|
23 | | -class ToolkitCompilationTest extends CatsEffectSuite { |
| 24 | +object ToolkitCompilationTest extends SimpleIOSuite { |
24 | 25 |
|
25 | | - // 2 minutes may seem a lot, but consider that the first test for |
| 26 | + // 4 minutes may seem a lot, but consider that the first test for |
26 | 27 | // each (scalaVersion, platform) will have to download the compiler |
27 | 28 | // (if it's not the default), compile (that for native takes awhile) |
28 | 29 | // and then finally run the code. |
29 | | - override def munitIOTimeout: Duration = 2.minute |
| 30 | + private val TestTimeout = 4.minutes |
| 31 | + |
| 32 | + // We can disable parallelism for this suite, since it is CPU-bound anyway. |
| 33 | + override val maxParallelism = 1 |
30 | 34 |
|
31 | 35 | testRun("Toolkit should run a simple Hello Cats Effect") { |
32 | 36 | if (scala3) |
@@ -67,26 +71,36 @@ class ToolkitCompilationTest extends CatsEffectSuite { |
67 | 71 | |}""" |
68 | 72 | } |
69 | 73 |
|
70 | | - testTest("Toolkit should execute a simple munit suite") { |
| 74 | + testTest("Toolkit should execute a simple weaver suite") { |
71 | 75 | if (scala3) |
72 | | - """|import cats.effect.* |
73 | | - |import munit.* |
| 76 | + """|import cats.effect.IO |
| 77 | + |import weaver.* |
74 | 78 | | |
75 | | - |class Test extends CatsEffectSuite: |
76 | | - | test("test")(IO.unit)""" |
| 79 | + |object Test extends SimpleIOSuite: |
| 80 | + | test("test")(IO.pure(success))""" |
77 | 81 | else |
78 | | - """|import cats.effect._ |
79 | | - |import munit._ |
| 82 | + """|import cats.effect.IO |
| 83 | + |import weaver._ |
80 | 84 | | |
81 | | - |class Test extends CatsEffectSuite { |
82 | | - | test("test")(IO.unit) |
| 85 | + |object Test extends SimpleIOSuite { |
| 86 | + | test("test")(IO.pure(success)) |
83 | 87 | |}""" |
84 | 88 | } |
85 | 89 |
|
86 | | - def testRun(testName: TestOptions)(scriptBody: String): Unit = |
87 | | - test(testName)(ScalaCliProcess.run(scriptBody)) |
| 90 | + private def withTimeout(test: IO[Expectations]): IO[Expectations] = |
| 91 | + test.timeoutTo( |
| 92 | + TestTimeout, |
| 93 | + IO.pure(failure(s"Test exceeded timeout of $TestTimeout")) |
| 94 | + ) |
| 95 | + |
| 96 | + def testRun(testName: String)(scriptBody: String): Unit = |
| 97 | + test(testName) { |
| 98 | + withTimeout(ScalaCliProcess.run(scriptBody)) |
| 99 | + } |
88 | 100 |
|
89 | | - def testTest(testName: TestOptions)(scriptBody: String): Unit = |
90 | | - test(testName)(ScalaCliProcess.test(scriptBody)) |
| 101 | + def testTest(testName: String)(scriptBody: String): Unit = |
| 102 | + test(testName) { |
| 103 | + withTimeout(ScalaCliProcess.test(scriptBody)) |
| 104 | + } |
91 | 105 |
|
92 | 106 | } |
0 commit comments