diff --git a/src/it/scala/inox/TestSuite.scala b/src/it/scala/inox/TestSuite.scala index 4787ce3b0d009de59b13f4bad413e830ec011d1c..a924f2eb635addf4a53f7da09a8f06742313cef5 100644 --- a/src/it/scala/inox/TestSuite.scala +++ b/src/it/scala/inox/TestSuite.scala @@ -22,40 +22,49 @@ trait TestSuite extends FunSuite with Matchers with Timeouts { } protected def test(name: String, tags: Tag*)(body: Context => Unit): Unit = { - test(name, _ => true, tags : _*)(body) + test(name, _ => Test, tags : _*)(body) } - protected def test(name: String, filter: Context => Boolean, tags: Tag*)(body: Context => Unit): Unit = { + sealed abstract class FilterStatus + case object Test extends FilterStatus + case object Ignore extends FilterStatus + case object Skip extends FilterStatus + + protected def test(name: String, filter: Context => FilterStatus, tags: Tag*)(body: Context => Unit): Unit = { for (config <- configurations) { val reporter = new TestSilentReporter val ctx = Context(reporter, new InterruptManager(reporter), Options(config)) - if (filter(ctx)) try { - val index = counter.nextGlobal - if (ctx.options.findOptionOrDefault(optSelectedSolvers).exists { sname => - (sname == "nativez3" || sname == "unrollz3") && !solvers.SolverFactory.hasNativeZ3 || - sname == "smt-z3" && !solvers.SolverFactory.hasZ3 || - sname == "smt-cvc4" && !solvers.SolverFactory.hasCVC4 - }) { - super.ignore(f"$index%3d: $name ${optionsString(ctx.options)}")(()) - } else { - super.test(f"$index%3d: $name ${optionsString(ctx.options)}")(body(ctx)) - } - } catch { - case err: FatalError => - reporter.lastErrors :+= err.msg - throw new exceptions.TestFailedException(reporter.lastErrors.mkString("\n"), err, 5) + filter(ctx) match { + case status @ (Test | Ignore) => + val index = counter.nextGlobal + if (status == Ignore || ctx.options.findOptionOrDefault(optSelectedSolvers).exists { sname => + (sname == "nativez3" || sname == "unrollz3") && !solvers.SolverFactory.hasNativeZ3 || + sname == "smt-z3" && !solvers.SolverFactory.hasZ3 || + sname == "smt-cvc4" && !solvers.SolverFactory.hasCVC4 + }) { + super.ignore(f"$index%3d: $name ${optionsString(ctx.options)}")(()) + } else { + try { + super.test(f"$index%3d: $name ${optionsString(ctx.options)}")(body(ctx)) + } catch { + case err: FatalError => + reporter.lastErrors :+= err.msg + throw new exceptions.TestFailedException(reporter.lastErrors.mkString("\n"), err, 5) + } + } + case Skip => } } } protected def ignore(name: String, tags: Tag*)(body: Context => Unit): Unit = { - ignore(name, _ => true, tags : _*)(body) + test(name, _ => Ignore, tags : _*)(body) } - protected def ignore(name: String, filter: Context => Boolean, tags: Tag*)(body: Context => Unit): Unit = { - for (config <- configurations) { - val index = counter.nextGlobal - super.ignore(f"$index%3d: $name ${optionsString(Options(config))}")(()) - } + protected def ignore(name: String, filter: Context => FilterStatus, tags: Tag*)(body: Context => Unit): Unit = { + test(name, ctx => filter(ctx) match { + case Skip => Skip + case _ => Ignore + }, tags : _*)(body) } } diff --git a/src/it/scala/inox/solvers/unrolling/InductiveUnrollingSuite.scala b/src/it/scala/inox/solvers/unrolling/InductiveUnrollingSuite.scala index a97bc2e516668f0403101a47616832aa67267719..2481c868ce04ba9faccba0542e65692a6925d501 100644 --- a/src/it/scala/inox/solvers/unrolling/InductiveUnrollingSuite.scala +++ b/src/it/scala/inox/solvers/unrolling/InductiveUnrollingSuite.scala @@ -185,23 +185,22 @@ class InductiveUnrollingSuite extends SolvingTestSuite with DatastructureUtils { assert(SimpleSolverAPI(SolverFactory.default(program)).solveSAT(clause).isUNSAT) } - def filterPrincess(ctx: Context): Boolean = { + def filterPrincess(ctx: Context, allowSelect: Boolean = true): FilterStatus = { val solvers = ctx.options.findOptionOrDefault(optSelectedSolvers) val feelingLucky = ctx.options.findOptionOrDefault(optFeelingLucky) val checkModels = ctx.options.findOptionOrDefault(optCheckModels) val unrollAssume = ctx.options.findOptionOrDefault(optUnrollAssumptions) - solvers != Set("princess") || { - (feelingLucky && checkModels && unrollAssume) || - (!feelingLucky && !checkModels && !unrollAssume) - } + if (solvers == Set("princess") && + (!allowSelect || feelingLucky != checkModels || checkModels != unrollAssume)) Skip + else Test } - test("flatMap is associative", filterPrincess _) { ctx => + test("flatMap is associative", filterPrincess(_)) { ctx => val program = InoxProgram(ctx, symbols) assert(SimpleSolverAPI(SolverFactory.default(program)).solveSAT(Not(associative.fullBody)).isUNSAT) } - test("sort preserves content 1", filterPrincess _) { ctx => + test("sort preserves content 1", filterPrincess(_)) { ctx => val program = InoxProgram(ctx, symbols) val (l,p) = ("l" :: T(listID)(IntegerType), "p" :: ((IntegerType, IntegerType) =>: BooleanType)) val clause = E(contentID)(IntegerType)(E(sortID)(IntegerType)(l.toVariable, p.toVariable)) === @@ -209,7 +208,7 @@ class InductiveUnrollingSuite extends SolvingTestSuite with DatastructureUtils { assert(SimpleSolverAPI(SolverFactory.default(program)).solveSAT(Not(clause)).isUNSAT) } - test("sort preserves content 2", _.options.findOptionOrDefault(optSelectedSolvers) != Set("princess")) { ctx => + test("sort preserves content 2", filterPrincess(_, allowSelect = false)) { ctx => val program = InoxProgram(ctx, symbols) import program._ diff --git a/src/it/scala/inox/solvers/unrolling/SimpleUnrollingSuite.scala b/src/it/scala/inox/solvers/unrolling/SimpleUnrollingSuite.scala index 9912471668ef692f76026ea1e29d7679d1b4404d..b8b1d53c75cd2f5c709d79e028510fa59fbb4e29 100644 --- a/src/it/scala/inox/solvers/unrolling/SimpleUnrollingSuite.scala +++ b/src/it/scala/inox/solvers/unrolling/SimpleUnrollingSuite.scala @@ -80,7 +80,10 @@ class SimpleUnrollingSuite extends SolvingTestSuite { } } - test("size(x) < 0 is not satisfiable (unknown)") { ctx => + test("size(x) < 0 is not satisfiable (unknown)", ctx => { + if (ctx.options.findOptionOrDefault(optSelectedSolvers) contains "princess") Ignore + else Test + }) { ctx => val program = InoxProgram(ctx, symbols) val vd: ValDef = "x" :: T(listID)(IntegerType)