mirror of https://github.com/sbt/sbt.git
Fixes flaky no-such-element exception from bad generation of random tests.
This commit is contained in:
parent
d1aa2089fe
commit
515ec1f2e2
|
|
@ -41,10 +41,11 @@ object SettingsTest extends Properties("settings") {
|
||||||
final def derivedSettings(nr: Int): Prop =
|
final def derivedSettings(nr: Int): Prop =
|
||||||
{
|
{
|
||||||
val genScopedKeys = {
|
val genScopedKeys = {
|
||||||
val attrKeys = mkAttrKeys[Int](nr)
|
val attrKeys = mkAttrKeys[Int](nr).filter(!_.isEmpty)
|
||||||
attrKeys map (_ map (ak => ScopedKey(Scope(0), ak)))
|
attrKeys map (_ map (ak => ScopedKey(Scope(0), ak)))
|
||||||
}
|
}.label("scopedKeys")
|
||||||
forAll(genScopedKeys) { scopedKeys =>
|
forAll(genScopedKeys) { scopedKeys =>
|
||||||
|
// 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]] = (
|
||||||
for {
|
for {
|
||||||
|
|
@ -65,10 +66,10 @@ object SettingsTest extends Properties("settings") {
|
||||||
val nonEmptyAlphaStr =
|
val nonEmptyAlphaStr =
|
||||||
nonEmptyListOf(alphaChar).map(_.mkString).suchThat(_.forall(_.isLetter))
|
nonEmptyListOf(alphaChar).map(_.mkString).suchThat(_.forall(_.isLetter))
|
||||||
|
|
||||||
for {
|
(for {
|
||||||
list <- Gen.listOfN(nr, nonEmptyAlphaStr) suchThat (l => l.size == l.distinct.size)
|
list <- Gen.listOfN(nr, nonEmptyAlphaStr) suchThat (l => l.size == l.distinct.size)
|
||||||
item <- list
|
item <- list
|
||||||
} yield AttributeKey[T](item)
|
} yield AttributeKey[T](item)).label(s"mkAttrKeys($nr)")
|
||||||
}
|
}
|
||||||
|
|
||||||
property("Derived setting(s) replace DerivedSetting in the Seq[Setting[_]]") = derivedKeepsPosition
|
property("Derived setting(s) replace DerivedSetting in the Seq[Setting[_]]") = derivedKeepsPosition
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue