-
Notifications
You must be signed in to change notification settings - Fork 101
Teardown not invoked on Ctrl-C / SIGINT #1037
Copy link
Copy link
Open
Description
Originally reported as typelevel/munit-cats-effect#467
Looks like FunFixture.async teardown is not invoked when tests are interrupted with Ctrl-C or SIGINT
build.sbt
scalaVersion := "3.8.1"
libraryDependencies ++= Seq(
"org.scalameta" %% "munit" % "1.2.1" % Test,
)
Test / fork := true // needed for Ctrl-C to gracefully terminate testssrc/test/scala/FunFixtureAsyncTest.scala
import munit.FunSuite
import scala.concurrent.Future
class FunFixtureAsyncTest extends FunSuite {
val fixture = FunFixture.async[Unit](
setup = { testOptions =>
println("setup")
Future.successful(())
},
teardown = { _ =>
println("teardown")
Future.successful(())
}
)
fixture.test("async fixture test") { _ =>
println("running test")
Thread.sleep(5000)
Future.successful {
assert(true)
}
}
}sbt "testOnly FunFixtureAsyncTest" and press Ctrl-C when sleeping
Result:
setup
running test
^C
[warn] Canceling execution...
Cancelled: testOnly FunFixtureAsyncTest
[error] Cancelled: testOnly FunFixtureAsyncTest
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels