sbt/launch/src/test/scala/ConfigurationParserTest.scala

92 lines
4.9 KiB
Scala
Raw Normal View History

package xsbt.boot
2014-05-07 17:52:23 +02:00
import java.io.{ File, InputStream }
import java.net.URL
import java.util.Properties
import xsbti._
import org.specs2._
import mutable.Specification
2014-05-07 17:52:23 +02:00
import sbt.IO.{ createDirectory, touch, withTemporaryDirectory }
2014-05-07 17:52:23 +02:00
object ConfigurationParserTest extends Specification {
"Configuration Parser" should {
"Correctly parse bootOnly" in {
2014-05-07 17:52:23 +02:00
repoFileContains("""|[repositories]
| local: bootOnly""".stripMargin,
2014-05-07 17:52:23 +02:00
Repository.Predefined("local", true))
2014-05-07 17:52:23 +02:00
repoFileContains("""|[repositories]
| local""".stripMargin,
2014-05-07 17:52:23 +02:00
Repository.Predefined("local", false))
2014-05-07 17:52:23 +02:00
repoFileContains("""|[repositories]
| id: http://repo1.maven.org""".stripMargin,
2014-05-07 17:52:23 +02:00
Repository.Maven("id", new URL("http://repo1.maven.org"), false))
2014-05-07 17:52:23 +02:00
repoFileContains("""|[repositories]
| id: http://repo1.maven.org, bootOnly""".stripMargin,
2014-05-07 17:52:23 +02:00
Repository.Maven("id", new URL("http://repo1.maven.org"), true))
2014-05-07 17:52:23 +02:00
repoFileContains("""|[repositories]
| id: http://repo1.maven.org, [orgPath]""".stripMargin,
2014-05-07 17:52:23 +02:00
Repository.Ivy("id", new URL("http://repo1.maven.org"), "[orgPath]", "[orgPath]", false, false))
2014-05-07 17:52:23 +02:00
repoFileContains("""|[repositories]
| id: http://repo1.maven.org, [orgPath], mavenCompatible""".stripMargin,
2014-05-07 17:52:23 +02:00
Repository.Ivy("id", new URL("http://repo1.maven.org"), "[orgPath]", "[orgPath]", true, false))
2014-05-07 17:52:23 +02:00
repoFileContains("""|[repositories]
| id: http://repo1.maven.org, [orgPath], mavenCompatible, bootOnly""".stripMargin,
2014-05-07 17:52:23 +02:00
Repository.Ivy("id", new URL("http://repo1.maven.org"), "[orgPath]", "[orgPath]", true, true))
2014-05-07 17:52:23 +02:00
repoFileContains("""|[repositories]
| id: http://repo1.maven.org, [orgPath], bootOnly, mavenCompatible""".stripMargin,
2014-05-07 17:52:23 +02:00
Repository.Ivy("id", new URL("http://repo1.maven.org"), "[orgPath]", "[orgPath]", true, true))
2014-05-07 17:52:23 +02:00
repoFileContains("""|[repositories]
| id: http://repo1.maven.org, [orgPath], bootOnly""".stripMargin,
2014-05-07 17:52:23 +02:00
Repository.Ivy("id", new URL("http://repo1.maven.org"), "[orgPath]", "[orgPath]", false, true))
2014-05-07 17:52:23 +02:00
repoFileContains("""|[repositories]
| id: http://repo1.maven.org, [orgPath], [artPath]""".stripMargin,
2014-05-07 17:52:23 +02:00
Repository.Ivy("id", new URL("http://repo1.maven.org"), "[orgPath]", "[artPath]", false, false))
2014-05-07 17:52:23 +02:00
repoFileContains("""|[repositories]
| id: http://repo1.maven.org, [orgPath], [artPath], descriptorOptional""".stripMargin,
2014-05-07 17:52:23 +02:00
Repository.Ivy("id", new URL("http://repo1.maven.org"), "[orgPath]", "[artPath]", false, false, true, false))
2014-05-07 17:52:23 +02:00
repoFileContains("""|[repositories]
| id: http://repo1.maven.org, [orgPath], [artPath], descriptorOptional, skipConsistencyCheck""".stripMargin,
2014-05-07 17:52:23 +02:00
Repository.Ivy("id", new URL("http://repo1.maven.org"), "[orgPath]", "[artPath]", false, false, true, true))
2014-05-07 17:52:23 +02:00
repoFileContains("""|[repositories]
| id: http://repo1.maven.org, [orgPath], [artPath], skipConsistencyCheck, descriptorOptional""".stripMargin,
2014-05-07 17:52:23 +02:00
Repository.Ivy("id", new URL("http://repo1.maven.org"), "[orgPath]", "[artPath]", false, false, true, true))
2014-05-07 17:52:23 +02:00
repoFileContains("""|[repositories]
| id: http://repo1.maven.org, [orgPath], [artPath], skipConsistencyCheck, descriptorOptional, mavenCompatible, bootOnly""".stripMargin,
2014-05-07 17:52:23 +02:00
Repository.Ivy("id", new URL("http://repo1.maven.org"), "[orgPath]", "[artPath]", true, true, true, true))
2014-05-07 17:52:23 +02:00
repoFileContains("""|[repositories]
| id: http://repo1.maven.org, [orgPath], [artPath], bootOnly""".stripMargin,
2014-05-07 17:52:23 +02:00
Repository.Ivy("id", new URL("http://repo1.maven.org"), "[orgPath]", "[artPath]", false, true))
2014-05-07 17:52:23 +02:00
repoFileContains("""|[repositories]
| id: http://repo1.maven.org, [orgPath], [artPath], bootOnly, mavenCompatible""".stripMargin,
2014-05-07 17:52:23 +02:00
Repository.Ivy("id", new URL("http://repo1.maven.org"), "[orgPath]", "[artPath]", true, true))
2014-05-07 17:52:23 +02:00
repoFileContains("""|[repositories]
| id: http://repo1.maven.org, [orgPath], [artPath], mavenCompatible, bootOnly""".stripMargin,
2014-05-07 17:52:23 +02:00
Repository.Ivy("id", new URL("http://repo1.maven.org"), "[orgPath]", "[artPath]", true, true))
2014-05-07 17:52:23 +02:00
}
}
def repoFileContains(file: String, repo: Repository.Repository) =
loadRepoFile(file) must contain(repo)
2014-05-07 17:52:23 +02:00
def loadRepoFile(file: String) =
(new ConfigurationParser) readRepositoriesConfig file
}