diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-12-31 22:56:45 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-01 10:10:19 -0800 |
commit | cf5fb5fdfd477e0bb4ffa0e4fec3a8ec01bf5cf1 (patch) | |
tree | f3897463b6f55019f2bbd59ba5cff73cf0fb571f /integration/src/test/scala | |
parent | 6996c01a391cb9aaa27268dd1f0cf0a1749ade21 (diff) | |
download | mill-cf5fb5fdfd477e0bb4ffa0e4fec3a8ec01bf5cf1.tar.gz mill-cf5fb5fdfd477e0bb4ffa0e4fec3a8ec01bf5cf1.tar.bz2 mill-cf5fb5fdfd477e0bb4ffa0e4fec3a8ec01bf5cf1.zip |
Split Acyclic/Jawn/BetterFiles tests into their own `integration/` test suite.
Those tests now download a snapshot of the relevant git repo rather than vendoring the files, and use a bare `build.sc` instead of having the build object be included in the test classpath.
Tests pass using `sbt integration/test`, but `mill integration.test` still doesn't work
Diffstat (limited to 'integration/src/test/scala')
4 files changed, 111 insertions, 0 deletions
diff --git a/integration/src/test/scala/mill/integration/AcyclicTests.scala b/integration/src/test/scala/mill/integration/AcyclicTests.scala new file mode 100644 index 00000000..cd7209d5 --- /dev/null +++ b/integration/src/test/scala/mill/integration/AcyclicTests.scala @@ -0,0 +1,34 @@ +package mill.integration + +import ammonite.ops._ +import utest._ + +object AcyclicTests extends IntegrationTestSuite("MILL_ACYCLIC_REPO", "acyclic") { + val tests = Tests{ + initWorkspace() + + def check(scalaVersion: String) = { + val firstCompile = eval(s"acyclic[$scalaVersion].compile") + + assert( + firstCompile, + ls.rec(workspacePath).exists(_.last == "GraphAnalysis.class"), + ls.rec(workspacePath).exists(_.last == "PluginPhase.class") + ) + for(scalaFile <- ls.rec(workspacePath).filter(_.ext == "scala")){ + write.append(scalaFile, "\n}") + } + + val brokenCompile = eval(s"acyclic[$scalaVersion].compile") + + assert(!brokenCompile) + } + + 'scala2118 - check("2.11.8") + 'scala2124 - check("2.12.4") + + } + def main(args: Array[String]): Unit = { + println("Integration Main") + } +} diff --git a/integration/src/test/scala/mill/integration/BetterFilesTests.scala b/integration/src/test/scala/mill/integration/BetterFilesTests.scala new file mode 100644 index 00000000..b14709a4 --- /dev/null +++ b/integration/src/test/scala/mill/integration/BetterFilesTests.scala @@ -0,0 +1,21 @@ +package mill.integration + +import ammonite.ops._ +import utest._ + +object BetterFilesTests extends IntegrationTestSuite("MILL_BETTERFILES_REPO", "better-files") { + val tests = Tests{ + initWorkspace() + 'test - { + + assert(eval("Core.test")) + assert(eval("Akka.test")) + + for(scalaFile <- ls.rec(workspacePath).filter(_.ext == "scala")){ + write.append(scalaFile, "\n}") + } + assert(!eval("Akka.test")) + } + + } +} diff --git a/integration/src/test/scala/mill/integration/IntegrationTestSuite.scala b/integration/src/test/scala/mill/integration/IntegrationTestSuite.scala new file mode 100644 index 00000000..e79eebe0 --- /dev/null +++ b/integration/src/test/scala/mill/integration/IntegrationTestSuite.scala @@ -0,0 +1,23 @@ +package mill.integration + +import ammonite.ops._ +import utest._ + +abstract class IntegrationTestSuite(repoKey: String, workspaceSlug: String) extends TestSuite{ + val workspacePath = pwd / 'target / 'workspace / workspaceSlug + val buildFilePath = pwd / 'integration / 'src / 'test / 'resource / workspaceSlug + val runner = new mill.main.MainRunner(ammonite.main.Cli.Config(wd = workspacePath), false) + def eval(s: String*) = runner.runScript(workspacePath / "build.sc", s.toList) + def initWorkspace() = { + rm(workspacePath) + mkdir(workspacePath / up) + // The unzipped git repo snapshots we get from github come with a + // wrapper-folder inside the zip file, so copy the wrapper folder to the + // destination instead of the folder containing the wrapper. + val path = sys.props(repoKey) + val Seq(wrapper) = ls(Path(path)) + cp(wrapper, workspacePath) + cp(buildFilePath / "build.sc", workspacePath / "build.sc") + assert(!ls.rec(workspacePath).exists(_.ext == "class")) + } +} diff --git a/integration/src/test/scala/mill/integration/JawnTests.scala b/integration/src/test/scala/mill/integration/JawnTests.scala new file mode 100644 index 00000000..adf6e688 --- /dev/null +++ b/integration/src/test/scala/mill/integration/JawnTests.scala @@ -0,0 +1,33 @@ +package mill.integration + +import ammonite.ops._ +import utest._ + +object JawnTests extends IntegrationTestSuite("MILL_JAWN_REPO", "jawn") { + val tests = Tests{ + initWorkspace() + + def check(scalaVersion: String) = { + val firstCompile = eval(s"jawn[$scalaVersion].Parser.test") + + assert( + firstCompile, + ls.rec(workspacePath).exists(_.last == "AsyncParser.class"), + ls.rec(workspacePath).exists(_.last == "CharBuilderSpec.class") + ) + + pprint.log(ls.rec(workspacePath).map(_.toString), height=9999) + pprint.log(ls.rec(workspacePath).find(_.ext == "scala")) + for(scalaFile <- ls.rec(workspacePath).filter(_.ext == "scala")){ + write.append(scalaFile, "\n}") + } + + val brokenCompile = eval(s"jawn[$scalaVersion].Parser.test") + + assert(!brokenCompile) + } + + 'scala21111 - check("2.11.11") + 'scala2123 - check("2.12.3") + } +} |