Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Commands] Fix MatchError when using multiple workers #894

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ import org.scalacheck._

object CommandsSpecification extends Properties("Commands") {

property("commands") = TestCommands.property(threadCount = 4)
def prop = TestCommands.property(threadCount = 4)
property("commands") = prop

// `property(...) = prop` evaluates `prop` for each generation, while this will reuse the same value
val reusedProp = prop
property("commands with prop evaluated just once") = reusedProp

override def overrideParameters(p: Test.Parameters): Test.Parameters =
super.overrideParameters(p).withWorkers(2)

object TestCommands extends Commands {
case class Counter(var n: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ trait Commands {
Prop.forAll(actions(threadCount, maxParComb)) { as =>
try {
val sutId = suts.synchronized {
val initSuts = for((state,None) <- suts.values) yield state
val runningSuts = for((_,Some(sut)) <- suts.values) yield sut
val initSuts = suts.values.collect { case (state,None) => state }
val runningSuts = suts.values.collect { case (_, Some(sut)) => sut }
if (canCreateNewSut(as.s, initSuts, runningSuts)) {
val sutId = new AnyRef
suts += (sutId -> (as.s -> None))
Expand Down Expand Up @@ -252,7 +252,7 @@ trait Commands {
Prop.undecided
}
} catch { case e: Throwable =>
suts.synchronized { suts.clear }
suts.synchronized { suts.clear() }
throw e
}
}
Expand Down