From bc777b3c4e83149f45df7edda245868e22495eb3 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sun, 28 Jan 2018 22:43:40 -0800 Subject: Extract out `ScriptTestSuite` from `IntegrationTestSuite` and use it to create a version of `JavaCompilerJarTests` that runs through our main method & script runner. This should let us catch a lot of bugs with `MainRunner` and friends quickly, without needing to run the slow integration tests --- .../mill/integration/IntegrationTestSuite.scala | 35 +++++++--------------- 1 file changed, 11 insertions(+), 24 deletions(-) (limited to 'integration') diff --git a/integration/test/src/mill/integration/IntegrationTestSuite.scala b/integration/test/src/mill/integration/IntegrationTestSuite.scala index 043e4afa..4edecbe5 100644 --- a/integration/test/src/mill/integration/IntegrationTestSuite.scala +++ b/integration/test/src/mill/integration/IntegrationTestSuite.scala @@ -1,38 +1,25 @@ package mill.integration -import java.io.{ByteArrayInputStream, ByteArrayOutputStream, InputStream, PrintStream} - import ammonite.ops._ -import mill.define.Segments -import mill.main.ParseArgs +import mill.util.ScriptTestSuite import utest._ -abstract class IntegrationTestSuite(repoKey: String, workspaceSlug: String) extends TestSuite{ - val workspacePath = pwd / 'target / 'workspace / workspaceSlug +abstract class IntegrationTestSuite(repoKey: String, val workspaceSlug: String) + extends ScriptTestSuite{ val buildFilePath = pwd / 'integration / 'test / 'resources / workspaceSlug - val stdOutErr = new PrintStream(new ByteArrayOutputStream()) -// val stdOutErr = new PrintStream(System.out) - 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) + def scriptSourcePath = { // 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") + wrapper + } + + override def initWorkspace() = { + super.initWorkspace() + cp.over(buildFilePath / "build.sc", workspacePath / "build.sc") assert(!ls.rec(workspacePath).exists(_.ext == "class")) } } -- cgit v1.2.3