mirror of https://github.com/sbt/sbt.git
Test for extra properties files
This commit is contained in:
parent
a5bb434d2a
commit
092a42cf53
|
|
@ -0,0 +1 @@
|
|||
first.property=set-first
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
first.property=set-first
|
||||
second.property=set-second
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
project.name=test-env
|
||||
project.version=1.0
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
import sbt._
|
||||
|
||||
class Test(info: ProjectInfo) extends DefaultProject(info)
|
||||
{
|
||||
lazy val FirstDefault = "a"
|
||||
lazy val SecondDefault = "b"
|
||||
lazy val FirstSet = "set-first"
|
||||
lazy val SecondSet = "set-second"
|
||||
|
||||
lazy val extra = new BasicEnvironment
|
||||
{
|
||||
def log = Test.this.log
|
||||
def envBackingPath = info.builderPath / "extra.properties"
|
||||
|
||||
lazy val firstProperty = propertyOptional[String](FirstDefault)
|
||||
lazy val secondProperty = propertyOptional[String](SecondDefault)
|
||||
}
|
||||
|
||||
import extra.{firstProperty, secondProperty}
|
||||
|
||||
lazy val checkFirstUnset = checkTask(firstProperty, FirstDefault, "first.property")
|
||||
lazy val checkFirstSet = checkTask(firstProperty, FirstSet, "first.property")
|
||||
lazy val checkSecondUnset = checkTask(secondProperty, SecondDefault, "second.property")
|
||||
lazy val checkSecondSet = checkTask(secondProperty, SecondSet, "second.property")
|
||||
|
||||
def checkTask[T](property: extra.Property[T], expected: T, name: String): Task =
|
||||
task { if(property.value == expected) None else Some("Expected "+name+" to be '" + expected + "', was: " + property.value) }
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
# check that both properties are unset
|
||||
|
||||
> check-first-unset
|
||||
->check-first-set
|
||||
> check-second-unset
|
||||
->check-second-set
|
||||
|
||||
# create the extra properties file with only the first property set
|
||||
|
||||
$ copy-file changes/first.properties project/extra.properties
|
||||
> reload
|
||||
|
||||
-> check-first-unset
|
||||
>check-first-set
|
||||
> check-second-unset
|
||||
->check-second-set
|
||||
|
||||
# create the extra properties file with both properties set
|
||||
|
||||
$ copy-file changes/second.properties project/extra.properties
|
||||
> reload
|
||||
|
||||
-> check-first-unset
|
||||
>check-first-set
|
||||
-> check-second-unset
|
||||
>check-second-set
|
||||
Loading…
Reference in New Issue