Better test.

This commit is contained in:
Eugene Vigdorchik 2012-02-08 13:13:23 +04:00
parent be3ea741bc
commit aae19a4d0d
2 changed files with 26 additions and 7 deletions

View File

@ -5,17 +5,22 @@ object TestProject extends Build
{
lazy val root = Project("root", file(".")) settings(
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))),
libraryDependencies ++= Seq("log4j" % "log4j" % "1.2.14" force(),
"log4j" % "log4j" % "1.2.13"),
TaskKey[Unit]("check-forced") <<= check()
libraryDependencies <++= baseDirectory (libraryDeps),
TaskKey[Unit]("check-forced") <<= check("1.2.14"),
TaskKey[Unit]("check-depend") <<= check("1.2.13")
)
def check() =
def libraryDeps(base: File) = {
val slf4j = Seq("org.slf4j" % "slf4j-log4j12" % "1.1.0") // Uses log4j 1.2.13
if ((base / "force").exists) slf4j :+ ("log4j" % "log4j" % "1.2.14" force()) else slf4j
}
def check(ver: String) =
(dependencyClasspath in Compile) map { jars =>
val log4j = jars map (_.data) collect {
case f if f.getName contains "log4j" => f.getName
case f if f.getName contains "log4j-" => f.getName
}
if (log4j.size != 1 || !log4j.head.contains("1.2.14"))
if (log4j.size != 1 || !log4j.head.contains(ver))
error("Did not download the correct jar.")
}
}

View File

@ -1 +1,15 @@
> check-forced
#$ pause
$ touch force
#$ pause
> reload
#$ pause
> check-forced
-> check-depend
$ delete force
> reload
-> check-forced
> check-depend