Skip to content

Commit

Permalink
Modify test to reproduce typelevel#3554
Browse files Browse the repository at this point in the history
  • Loading branch information
durban committed Apr 24, 2023
1 parent 4109aef commit f521e9c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/shared/src/test/scala/cats/effect/std/MutexSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import org.specs2.specification.core.Fragments
import scala.concurrent.duration._

final class MutexSpec extends BaseSpec {

final override def executionTimeout = 10.minutes

"ConcurrentMutex" should {
tests(Mutex.concurrent[IO])
}
Expand Down Expand Up @@ -131,15 +134,15 @@ final class MutexSpec extends BaseSpec {
"handle cancelled acquire" in real {
val t = mutex.flatMap { m =>
val short = m.lock.use { _ => IO.sleep(5.millis) }
val long = m.lock.use { _ => IO.sleep(50.millis) }
val tsk = IO.race(short, long).flatMap { _ =>
val long = m.lock.use { _ => IO.sleep(20.millis) }
val tsk = IO.race(IO.race(short, short), IO.race(long, long)).flatMap { _ =>
// this will hang if a cancelled
// acquire left the mutex in an
// invalid state:
m.lock.use_
}

tsk.replicateA_(1000)
tsk.replicateA_(5000)
}

t mustEqual (())
Expand Down

0 comments on commit f521e9c

Please sign in to comment.