mirror of https://github.com/sbt/sbt.git
test for load/unload transformations
This commit is contained in:
parent
bf4d2a7a65
commit
966926a624
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
|
||||
{
|
||||
val loadCount = AttributeKey[Int]("load-count")
|
||||
val unloadCount = AttributeKey[Int]("unload-count")
|
||||
def f(key: AttributeKey[Int]) = (s: State) => {
|
||||
val previous = s get key getOrElse 0
|
||||
s.put(key, previous + 1)
|
||||
}
|
||||
seq(
|
||||
onLoad in Global ~= (f(loadCount) compose _),
|
||||
onUnload in Global ~= (f(unloadCount) compose _)
|
||||
)
|
||||
}
|
||||
|
||||
InputKey[Unit]("check-count") <<= inputTask { argsTask =>
|
||||
(argsTask, state) map { (args, s) =>
|
||||
def get(label: String) = s get AttributeKey[Int](label) getOrElse 0
|
||||
val loadCount = get("load-count")
|
||||
val unloadCount = get("unload-count")
|
||||
val expectedLoad = args(0).toInt
|
||||
val expectedUnload = args(1).toInt
|
||||
assert(expectedLoad == loadCount, "Expected load count: " + expectedLoad + ", got: " + loadCount)
|
||||
assert(expectedUnload == unloadCount, "Expected unload count: " + expectedUnload + ", got: " + unloadCount)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
> check-count 1 0
|
||||
> check-count 1 0
|
||||
> reload
|
||||
> check-count 2 1
|
||||
> set maxErrors := 1
|
||||
> check-count 3 2
|
||||
> reboot
|
||||
> check-count 1 0
|
||||
Loading…
Reference in New Issue