blob: 82f4de72bdbcfcb93c9507ad5b9b2830bad8b200 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package mill.integration
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, InputStream, PrintStream}
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 / 'resources / workspaceSlug
val stdOutErr = System.out//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) = read(workspacePath / "out" / RelPath(s.replaceAll("\\.", "/")) / "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"))
}
}
|