diff options
Diffstat (limited to 'integration/test/src')
5 files changed, 161 insertions, 0 deletions
diff --git a/integration/test/src/mill/integration/AcyclicTests.scala b/integration/test/src/mill/integration/AcyclicTests.scala new file mode 100644 index 00000000..42b5179b --- /dev/null +++ b/integration/test/src/mill/integration/AcyclicTests.scala @@ -0,0 +1,31 @@ +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") + + } +} diff --git a/integration/test/src/mill/integration/AmmoniteTests.scala b/integration/test/src/mill/integration/AmmoniteTests.scala new file mode 100644 index 00000000..22bd3cb8 --- /dev/null +++ b/integration/test/src/mill/integration/AmmoniteTests.scala @@ -0,0 +1,36 @@ +package mill.integration + +import ammonite.ops._ +import utest._ + +object AmmoniteTests extends IntegrationTestSuite("MILL_AMMONITE_REPO", "ammonite") { + val tests = Tests{ + initWorkspace() + + def check(scalaVersion: String) = { + val replTests = eval( + s"amm.repl[$scalaVersion].test", "{ammonite.unit,ammonite.session.ProjectTests.guava}" + ) + val replTestMeta = meta(s"amm.repl[$scalaVersion].test.test") + assert( + replTests, + replTestMeta.contains("ammonite.session.ProjectTests.guava"), + replTestMeta.contains("ammonite.unit.SourceTests.objectInfo.thirdPartyJava") + ) + + val compileResult = eval( + "--all", s"{shell,sshd,amm,integration}[$scalaVersion].test.compile" + ) + + assert( + compileResult, + ls.rec(workspacePath / 'out / 'integration / scalaVersion / 'test / 'compile) + .exists(_.name == "ErrorTruncationTests.class") + ) + } + + 'scala2118 - check("2.11.8") + 'scala2124 - check("2.12.4") + + } +} diff --git a/integration/test/src/mill/integration/BetterFilesTests.scala b/integration/test/src/mill/integration/BetterFilesTests.scala new file mode 100644 index 00000000..7ee943df --- /dev/null +++ b/integration/test/src/mill/integration/BetterFilesTests.scala @@ -0,0 +1,26 @@ +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")) + assert(eval("benchmarks.test.compile")) + + val coreTestMeta = meta("core.test.test") + assert(coreTestMeta.contains("better.files.FileSpec")) + assert(coreTestMeta.contains("files should handle BOM")) + + for(scalaFile <- ls.rec(workspacePath).filter(_.ext == "scala")){ + write.append(scalaFile, "\n}") + } + assert(!eval("akka.test")) + } + + } +} diff --git a/integration/test/src/mill/integration/IntegrationTestSuite.scala b/integration/test/src/mill/integration/IntegrationTestSuite.scala new file mode 100644 index 00000000..4649abdb --- /dev/null +++ b/integration/test/src/mill/integration/IntegrationTestSuite.scala @@ -0,0 +1,37 @@ +package mill.integration + +import java.io.{ByteArrayInputStream, ByteArrayOutputStream, InputStream, PrintStream} + +import ammonite.ops._ +import mill.define.Segments +import mill.main.ParseArgs +import utest._ + +abstract class IntegrationTestSuite(repoKey: String, workspaceSlug: String) extends TestSuite{ + val workspacePath = pwd / 'target / 'workspace / workspaceSlug + val buildFilePath = pwd / 'integration / 'test / 'resources / workspaceSlug + val stdOutErr = new PrintStream(new ByteArrayOutputStream()) + val stdIn = new ByteArrayInputStream(Array()) + val runner = new mill.main.MainRunner( + ammonite.main.Cli.Config(wd = workspacePath), false, + stdOutErr, stdOutErr, stdIn + ) + def eval(s: String*) = runner.runScript(workspacePath / "build.sc", s.toList) + def meta(s: String) = { + val (List(selector), args) = ParseArgs.apply(Seq(s)).right.get + + read(workspacePath / "out" / selector.flatMap(_.pathSegments) / "meta.json") + } + 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/test/src/mill/integration/JawnTests.scala b/integration/test/src/mill/integration/JawnTests.scala new file mode 100644 index 00000000..21c9f133 --- /dev/null +++ b/integration/test/src/mill/integration/JawnTests.scala @@ -0,0 +1,31 @@ +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") + ) + + 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") + } +} |