mirror of https://github.com/sbt/sbt.git
Demonstrate failure to process property absence directives in profile activation
This commit is contained in:
parent
f0e20106db
commit
b8207607c9
|
|
@ -77,6 +77,41 @@ object PomParsingTests extends TestSuite {
|
||||||
|
|
||||||
assert(result == expected)
|
assert(result == expected)
|
||||||
}
|
}
|
||||||
|
'readProfileActiveByPropertyWithoutValue{
|
||||||
|
val profileNode ="""
|
||||||
|
<profile>
|
||||||
|
<id>profile1</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>hadoop.profile</name>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
</profile>
|
||||||
|
"""
|
||||||
|
val expected = \/-(Profile("profile1", None, Profile.Activation(List("hadoop.profile" -> None)), Nil, Nil, Map.empty))
|
||||||
|
val result = Pom.profile(xmlParse(profileNode).right.get)
|
||||||
|
|
||||||
|
assert(result == expected)
|
||||||
|
}
|
||||||
|
|
||||||
|
'readProfileActiveByPropertyWithValue{
|
||||||
|
val profileNode ="""
|
||||||
|
<profile>
|
||||||
|
<id>profile1</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>hadoop.profile</name>
|
||||||
|
<value>yes</value>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
</profile>
|
||||||
|
"""
|
||||||
|
val expected = \/-(Profile("profile1", None, Profile.Activation(List("hadoop.profile" -> Some("yes"))), Nil, Nil, Map.empty))
|
||||||
|
val result = Pom.profile(xmlParse(profileNode).right.get)
|
||||||
|
|
||||||
|
assert(result == expected)
|
||||||
|
}
|
||||||
|
|
||||||
'readProfileDependencies{
|
'readProfileDependencies{
|
||||||
val profileNode ="""
|
val profileNode ="""
|
||||||
<profile>
|
<profile>
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,30 @@ object ResolutionTests extends TestSuite {
|
||||||
Profile("default", activation = Profile.Activation(properties = Seq("special" -> Some("!false"))), dependencies = Seq(
|
Profile("default", activation = Profile.Activation(properties = Seq("special" -> Some("!false"))), dependencies = Seq(
|
||||||
"" -> Dependency(Module("org.escalier", "librairie-standard"), "2.11.6"))))),
|
"" -> Dependency(Module("org.escalier", "librairie-standard"), "2.11.6"))))),
|
||||||
|
|
||||||
|
Project(Module("com.github.dummy", "libb"), "0.5.7",
|
||||||
|
// This project demonstrates a build profile that activates only when
|
||||||
|
// the property "special" is unset. Because "special" is set to "true"
|
||||||
|
// here, the build profile should not be active and "librairie-standard"
|
||||||
|
// should not be provided as a transitive dependency when resolved.
|
||||||
|
//
|
||||||
|
// We additionally include the property "!special" -> "true" to
|
||||||
|
// disambiguate the absence of the "special" property versus
|
||||||
|
// the presence of the "!special" property (which is probably not valid pom
|
||||||
|
// anyways)
|
||||||
|
properties = Seq("special" -> "true", "!special" -> "true"),
|
||||||
|
profiles = Seq(
|
||||||
|
Profile("default", activation = Profile.Activation(properties = Seq("!special" -> None)), dependencies = Seq(
|
||||||
|
"" -> Dependency(Module("org.escalier", "librairie-standard"), "2.11.6"))))),
|
||||||
|
|
||||||
|
Project(Module("com.github.dummy", "libb"), "0.5.8",
|
||||||
|
// This project demonstrates a build profile that activates only when
|
||||||
|
// the property "special" is unset. Because that is the case here,
|
||||||
|
// the "default" build profile should be active and "librairie-standard"
|
||||||
|
// should be provided as a transitive dependency when resolved.
|
||||||
|
profiles = Seq(
|
||||||
|
Profile("default", activation = Profile.Activation(properties = Seq("!special" -> None)), dependencies = Seq(
|
||||||
|
"" -> Dependency(Module("org.escalier", "librairie-standard"), "2.11.6"))))),
|
||||||
|
|
||||||
Project(Module("an-org", "a-name"), "1.0"),
|
Project(Module("an-org", "a-name"), "1.0"),
|
||||||
|
|
||||||
Project(Module("an-org", "a-name"), "1.2"),
|
Project(Module("an-org", "a-name"), "1.2"),
|
||||||
|
|
@ -398,7 +422,7 @@ object ResolutionTests extends TestSuite {
|
||||||
}
|
}
|
||||||
'depsFromPropertyActivatedProfile{
|
'depsFromPropertyActivatedProfile{
|
||||||
val f =
|
val f =
|
||||||
for (version <- Seq("0.5.3", "0.5.4", "0.5.5", "0.5.6")) yield {
|
for (version <- Seq("0.5.3", "0.5.4", "0.5.5", "0.5.6", "0.5.8")) yield {
|
||||||
async {
|
async {
|
||||||
val dep = Dependency(Module("com.github.dummy", "libb"), version)
|
val dep = Dependency(Module("com.github.dummy", "libb"), version)
|
||||||
val trDeps = Seq(
|
val trDeps = Seq(
|
||||||
|
|
@ -418,6 +442,30 @@ object ResolutionTests extends TestSuite {
|
||||||
|
|
||||||
scala.concurrent.Future.sequence(f)
|
scala.concurrent.Future.sequence(f)
|
||||||
}
|
}
|
||||||
|
'depsFromProfileDisactivatedByPropertyAbsence{
|
||||||
|
// A build profile only activates in the absence of some property should
|
||||||
|
// not be activated when that property is present.
|
||||||
|
// ---
|
||||||
|
// The target dependency in this test (com.github.dummy % libb % 0.5.7)
|
||||||
|
// declares a profile that is only active when name=!special,
|
||||||
|
// and names a transitive dependency (librairie-standard) that is only
|
||||||
|
// active under that build profile. When we resolve a module with
|
||||||
|
// the "special" attribute set to "true", the transitive dependency
|
||||||
|
// should not appear.
|
||||||
|
async {
|
||||||
|
val dep = Dependency(Module("com.github.dummy", "libb"), "0.5.7")
|
||||||
|
val res = await(resolve0(
|
||||||
|
Set(dep)
|
||||||
|
)).clearCaches
|
||||||
|
|
||||||
|
val expected = Resolution(
|
||||||
|
rootDependencies = Set(dep),
|
||||||
|
dependencies = Set(dep.withCompileScope)
|
||||||
|
)
|
||||||
|
|
||||||
|
assert(res == expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
'depsScopeOverrideFromProfile{
|
'depsScopeOverrideFromProfile{
|
||||||
async {
|
async {
|
||||||
// Like com.google.inject:guice:3.0 with org.sonatype.sisu.inject:cglib
|
// Like com.google.inject:guice:3.0 with org.sonatype.sisu.inject:cglib
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue