use hedgehog.Result

This commit is contained in:
Eugene Yokota 2019-09-30 02:09:02 -04:00
parent f2de61c681
commit d1993bcabb
3 changed files with 11 additions and 10 deletions

View File

@ -9,7 +9,7 @@ package sbt
import sbt.internal.util.Types.idFun
import sbt.internal.TestBuild._
import hedgehog.{ Result => Assert, _ }
import hedgehog._
import hedgehog.Result.{ all, assert, failure, success }
import hedgehog.runner._
@ -116,14 +116,14 @@ object Delegates extends Properties {
)
)
def allAxes(f: (Scope, Seq[Scope], Scope => ScopeAxis[_]) => Assert): Property =
def allAxes(f: (Scope, Seq[Scope], Scope => ScopeAxis[_]) => hedgehog.Result): Property =
keysGen.forAll.map { keys =>
allDelegates(keys) { (s, ds) =>
all(List(f(s, ds, _.project), f(s, ds, _.config), f(s, ds, _.task), f(s, ds, _.extra)))
}
}
def allDelegates(keys: TestKeys)(f: (Scope, Seq[Scope]) => Assert): Assert =
def allDelegates(keys: TestKeys)(f: (Scope, Seq[Scope]) => hedgehog.Result): hedgehog.Result =
all(keys.scopes.map { scope =>
val delegates = keys.env.delegates(scope)
f(scope, delegates)
@ -131,14 +131,14 @@ object Delegates extends Properties {
.log("Delegates:\n\t" + delegates.map(scope => Scope.display(scope, "_")).mkString("\n\t"))
}.toList)
def alwaysZero(s: Scope, ds: Seq[Scope], axis: Scope => ScopeAxis[_]): Assert =
def alwaysZero(s: Scope, ds: Seq[Scope], axis: Scope => ScopeAxis[_]): hedgehog.Result =
assert(axis(s) != Zero).or(
all(ds.map { d =>
axis(d) ==== Zero
}.toList)
)
def globalCombinations(s: Scope, ds: Seq[Scope]): Assert = {
def globalCombinations(s: Scope, ds: Seq[Scope]): hedgehog.Result = {
val mods = List[Scope => Scope](
_.copy(project = Zero),
_.copy(config = Zero),

View File

@ -11,7 +11,7 @@ import sbt.Def.{ ScopedKey, displayFull, displayMasked }
import sbt.internal.TestBuild._
import sbt.internal.util.complete.Parser
import sbt.internal.{ Resolve, TestBuild }
import hedgehog.{ Result => Assert, _ }
import hedgehog._
import hedgehog.core.{ ShrinkLimit, SuccessCount }
import hedgehog.runner._
@ -64,7 +64,7 @@ object ParseKey extends Properties {
val expected = resolve(structure, key, mask)
parseCheck(structure, key, mask, showZeroConfig)(
sk =>
Assert
hedgehog.Result
.assert(Project.equal(sk, expected, mask))
.log(s"$sk.key == $expected.key: ${sk.key == expected.key}")
.log(s"${sk.scope} == ${expected.scope}: ${Scope.equal(sk.scope, expected.scope, mask)}")
@ -163,13 +163,13 @@ object ParseKey extends Properties {
key: ScopedKey[_],
mask: ScopeMask,
showZeroConfig: Boolean = false,
)(f: ScopedKey[_] => Assert): Assert = {
)(f: ScopedKey[_] => hedgehog.Result): hedgehog.Result = {
val s = displayMasked(key, mask, showZeroConfig)
val parser = makeParser(structure)
val parsed = Parser.result(parser, s).left.map(_().toString)
(
parsed
.fold(_ => Assert.failure, f)
.fold(_ => hedgehog.Result.failure, f)
.log(s"Key: ${Scope.displayPedantic(key.scope, key.key.label)}")
.log(s"Mask: $mask")
.log(s"Key string: '$s'")

View File

@ -5,10 +5,11 @@
* Licensed under Apache License 2.0 (see LICENSE)
*/
package sbt
import java.net.URI
import sbt.Def._
import sbt._
import sbt.internal.TestBuild
import sbt.internal.TestBuild._
import sbt.internal.util.AttributeKey