mirror of https://github.com/sbt/sbt.git
work on tests
This commit is contained in:
parent
1b147b4953
commit
f42c93901b
|
|
@ -180,7 +180,7 @@ class XSbt(info: ProjectInfo) extends ParentProject(info) with NoCrossPaths
|
|||
trait TestDependencies extends Project
|
||||
{
|
||||
val sc = "org.scala-tools.testing" % "scalacheck_2.8.0" % "1.7" % "test"
|
||||
val sp = "org.scala-tools.testing" % "specs_2.8.0" % "1.6.5" % "test"
|
||||
val sp = "org.scala-tools.testing" % "specs_2.8.1" % "1.6.7.2" % "test"
|
||||
}
|
||||
class LogProject(info: ProjectInfo) extends Base(info) with TestDependencies
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ object TaskGen
|
|||
// upper bounds to make the tests finish in reasonable time
|
||||
val MaxTasks = 100
|
||||
val MaxWorkers = 29
|
||||
val MaxJoin = 100
|
||||
val MaxJoin = 20
|
||||
|
||||
val MaxTasksGen = choose(0, MaxTasks)
|
||||
val MaxWorkersGen = choose(1, MaxWorkers)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
package sbt
|
||||
package std
|
||||
|
||||
import Types._
|
||||
import TaskExtra._
|
||||
import TaskTest.tryRun
|
||||
|
||||
import org.scalacheck._
|
||||
import Prop.forAll
|
||||
import Transform.taskToNode
|
||||
|
||||
object TaskSerial extends Properties("task serial")
|
||||
{
|
||||
val checkCycles = true
|
||||
val maxWorkers = 100
|
||||
|
||||
def eval[T](t: Task[T]): T = tryRun(t, checkCycles, maxWorkers)
|
||||
|
||||
property("Evaluates basic") = forAll { (i: Int) =>
|
||||
checkResult( eval( task(i) ), i )
|
||||
}
|
||||
|
||||
property("Evaluates Function0") = forAll { (i: Int) =>
|
||||
checkResult( eval( () => i ), i )
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
object TaskTest
|
||||
{
|
||||
def run[T](root: Task[T], checkCycles: Boolean, maxWorkers: Int): Result[T] =
|
||||
{
|
||||
val (service, shutdown) = CompletionService[Task[_], Completed](maxWorkers)
|
||||
|
||||
val x = new Execute[Task](checkCycles)(taskToNode)
|
||||
try { x.run(root)(service) } finally { shutdown() }
|
||||
}
|
||||
def tryRun[T](root: Task[T], checkCycles: Boolean, maxWorkers: Int): T =
|
||||
run(root, checkCycles, maxWorkers) match {
|
||||
case Value(v) => v
|
||||
case Inc(i) => throw i
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ import Prop._
|
|||
|
||||
import Process._
|
||||
|
||||
object ProcessSpecification extends Properties("Process I/O")
|
||||
private[this] object ProcessSpecification extends Properties("Process I/O")
|
||||
{
|
||||
implicit val exitCodeArb: Arbitrary[Array[Byte]] = Arbitrary(Gen.choose(0, 10) flatMap { size => Gen.resize(size, Arbitrary.arbArray[Byte].arbitrary) })
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue