Ok, this is actually the flaky issue with the test.

We use the ch key for testing, so it can't be part of the autogenerated set.
This commit is contained in:
Josh Suereth 2014-08-11 16:13:26 -04:00
parent 515ec1f2e2
commit dbc8b2643f
1 changed files with 27 additions and 14 deletions

View File

@ -37,14 +37,17 @@ object SettingsTest extends Properties("settings") {
evaluate(setting(chk, iterate(top)) :: Nil); true evaluate(setting(chk, iterate(top)) :: Nil); true
} }
property("Derived setting chain depending on (prev derived, normal setting)") = forAllNoShrink(Gen.choose(1, 100)) { derivedSettings } property("Derived setting chain depending on (prev derived, normal setting)") = forAllNoShrink(Gen.choose(1, 100).label("numSettings")) { derivedSettings }
final def derivedSettings(nr: Int): Prop = final def derivedSettings(nr: Int): Prop =
{ {
val genScopedKeys = { val genScopedKeys = {
val attrKeys = mkAttrKeys[Int](nr).filter(!_.isEmpty) // We wan
// t to generate lists of keys that DO NOT inclue the "ch" key we use to check thigns.
val attrKeys = mkAttrKeys[Int](nr).filter(_.forall(_.label != "ch"))
attrKeys map (_ map (ak => ScopedKey(Scope(0), ak))) attrKeys map (_ map (ak => ScopedKey(Scope(0), ak)))
}.label("scopedKeys") }.label("scopedKeys").filter(!_.isEmpty)
forAll(genScopedKeys) { scopedKeys => forAll(genScopedKeys) { scopedKeys =>
try {
// Note; It's evil to grab last IF you haven't verified the set can't be empty. // Note; It's evil to grab last IF you haven't verified the set can't be empty.
val last = scopedKeys.last val last = scopedKeys.last
val derivedSettings: Seq[Setting[Int]] = ( val derivedSettings: Seq[Setting[Int]] = (
@ -55,8 +58,18 @@ object SettingsTest extends Properties("settings") {
} yield derive(setting(scoped1, nextInit)) } yield derive(setting(scoped1, nextInit))
).toSeq ).toSeq
{ checkKey(last, Some(nr - 1), evaluate(setting(chk, value(0)) +: derivedSettings)) :| "Not derived?" } && {
{ checkKey(last, None, evaluate(derivedSettings)) :| "Should not be derived" } // Note: This causes a cycle refernec error, quite frequently.
checkKey(last, Some(nr - 1), evaluate(setting(chk, value(0)) +: derivedSettings)) :| "Not derived?"
} && {
checkKey(last, None, evaluate(derivedSettings)) :| "Should not be derived"
}
} catch {
case t: Throwable =>
// TODO - For debugging only.
t.printStackTrace(System.err)
throw t
}
} }
} }