diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-12-12 16:56:02 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-12 16:56:02 -0800 |
commit | 9ba4cb69331386dfde9bac69dc2d5b22401face3 (patch) | |
tree | 120349e8015ae5717d36bd44209cde6ff9543518 /scalalib/test/src/publish/IvyTests.scala | |
parent | ea7fceb6e56f53bde3517586dfc57e10a605a524 (diff) | |
download | mill-9ba4cb69331386dfde9bac69dc2d5b22401face3.tar.gz mill-9ba4cb69331386dfde9bac69dc2d5b22401face3.tar.bz2 mill-9ba4cb69331386dfde9bac69dc2d5b22401face3.zip |
collapse boilerplate folder structure within src/ folders (#505)
* collapse boilerplate folder structure within src/ folders
* .
Diffstat (limited to 'scalalib/test/src/publish/IvyTests.scala')
-rw-r--r-- | scalalib/test/src/publish/IvyTests.scala | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/scalalib/test/src/publish/IvyTests.scala b/scalalib/test/src/publish/IvyTests.scala new file mode 100644 index 00000000..d187f969 --- /dev/null +++ b/scalalib/test/src/publish/IvyTests.scala @@ -0,0 +1,60 @@ +package mill.scalalib.publish + +import utest._ +import mill._ + +import scala.xml.{Node, NodeSeq, XML} + +object IvyTests extends TestSuite { + + def tests: Tests = Tests { + val artifactId = "mill-scalalib_2.12" + val artifact = + Artifact("com.lihaoyi", "mill-scalalib_2.12", "0.0.1") + val deps = Agg( + Dependency(Artifact("com.lihaoyi", "mill-main_2.12", "0.1.4"), + Scope.Compile), + Dependency(Artifact("org.scala-sbt", "test-interface", "1.0"), + Scope.Compile), + Dependency(Artifact("com.lihaoyi", "pprint_2.12", "0.5.3"), + Scope.Compile, exclusions = List("com.lihaoyi" -> "fansi_2.12", "*" -> "sourcecode_2.12")) + ) + + 'fullIvy - { + val fullIvy = XML.loadString(Ivy(artifact, deps)) + + 'topLevel - { + val info = singleNode(fullIvy \ "info") + assert( + singleAttr(info, "organisation") == artifact.group, + singleAttr(info, "module") == artifact.id, + singleAttr(info, "revision") == artifact.version + ) + } + + 'dependencies - { + val dependencies = fullIvy \ "dependencies" \ "dependency" + val ivyDeps = deps.indexed + + assert(dependencies.size == ivyDeps.size) + + dependencies.zipWithIndex.foreach { case (dep, index) => + assert( + singleAttr(dep, "org") == ivyDeps(index).artifact.group, + singleAttr(dep, "name") == ivyDeps(index).artifact.id, + singleAttr(dep, "rev") == ivyDeps(index).artifact.version, + (dep \ "exclude").zipWithIndex forall { case (exclude, j) => + singleAttr(exclude, "org") == ivyDeps(index).exclusions(j)._1 && + singleAttr(exclude, "name") == ivyDeps(index).exclusions(j)._2 + } + ) + } + } + } + } + + def singleNode(seq: NodeSeq): Node = + seq.headOption.getOrElse(throw new RuntimeException("empty seq")) + def singleAttr(node: Node, attr: String): String = + node.attribute(attr).flatMap(_.headOption.map(_.text)).getOrElse(throw new RuntimeException(s"empty attr $attr")) +} |