Skip to content

Commit

Permalink
attempt to fix typelevel#360
Browse files Browse the repository at this point in the history
  • Loading branch information
ssanj committed Oct 23, 2017
1 parent bc672d9 commit 13c6b4a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/main/scala/org/scalacheck/ScalaCheckFramework.scala
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ private abstract class ScalaCheckRunner extends Runner {
names flatMap { name =>
import util.Pretty.{pretty, Params}

val params = applyCmdParams(properties.foldLeft(Parameters.default)((params, props) => props.overrideParameters(params)))
//If there are no command line arguments provided then override defaults with what is defined in the
//Property. If there are any command line arguments provided, override the values defined on the
//Property with those defined via the command line.
val paramsFromProperty = properties.foldLeft(Parameters.default)((params, props) => props.overrideParameters(params))
val noCmdArgsProvided = Parameters.hasSameCmdArgs(applyCmdParams(Parameters.default), Parameters.default)
val params = if (noCmdArgsProvided) paramsFromProperty else applyCmdParams(paramsFromProperty)

val propertyFilter = params.propFilter.map(_.r)

for ((`name`, prop) <- props) {
Expand Down
27 changes: 23 additions & 4 deletions src/main/scala/org/scalacheck/Test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,26 @@ object Test {
val initialSeed: Option[rng.Seed] = None
}

/**
* Compares if two supplied Parameters p1, p2 have equal values for all
* arguments that can be supplied via the command line:
* - minSuccessfulTests
* - minSize
* - maxSize
* - workers
* - maxDiscardRatio
* - propFilter
*
*/
def hasSameCmdArgs(p1: Parameters, p2: Parameters): Boolean = {
p1.minSuccessfulTests == p2.minSuccessfulTests &&
p1.minSize == p2.minSize &&
p1.maxSize == p2.maxSize &&
p1.workers == p2.workers &&
p1.maxDiscardRatio == p2.maxDiscardRatio &&
p1.propFilter == p2.propFilter
}

/** Verbose console reporter test parameters instance. */
val defaultVerbose: Parameters = default.withTestCallback(ConsoleReporter(2))
}
Expand Down Expand Up @@ -371,7 +391,6 @@ object Test {

/** Check a set of properties. */
def checkProperties(prms: Parameters, ps: Properties): Seq[(String,Result)] = {
val params = ps.overrideParameters(prms)
val propertyFilter = prms.propFilter.map(_.r)

ps.properties.filter {
Expand All @@ -380,12 +399,12 @@ object Test {
case (name, p) =>
val testCallback = new TestCallback {
override def onPropEval(n: String, t: Int, s: Int, d: Int) =
params.testCallback.onPropEval(name,t,s,d)
prms.testCallback.onPropEval(name,t,s,d)
override def onTestResult(n: String, r: Result) =
params.testCallback.onTestResult(name,r)
prms.testCallback.onTestResult(name,r)
}

val res = check(params.withTestCallback(testCallback), p)
val res = check(prms.withTestCallback(testCallback), p)
(name,res)
}
}
Expand Down

0 comments on commit 13c6b4a

Please sign in to comment.