summaryrefslogtreecommitdiff
path: root/main/test/src
diff options
context:
space:
mode:
Diffstat (limited to 'main/test/src')
-rw-r--r--main/test/src/mill/UTestFramework.scala4
-rw-r--r--main/test/src/mill/define/BasePathTests.scala9
-rw-r--r--main/test/src/mill/define/CacherTests.scala1
-rw-r--r--main/test/src/mill/eval/CrossTests.scala2
-rw-r--r--main/test/src/mill/eval/EvaluationTests.scala2
-rw-r--r--main/test/src/mill/eval/FailureTests.scala1
-rw-r--r--main/test/src/mill/eval/JavaCompileJarTests.scala35
-rw-r--r--main/test/src/mill/eval/ModuleTests.scala10
-rw-r--r--main/test/src/mill/eval/TaskTests.scala14
-rw-r--r--main/test/src/mill/main/ClientServerTests.scala5
-rw-r--r--main/test/src/mill/main/ForeignBuildsTest.scala5
-rw-r--r--main/test/src/mill/main/ForeignConflictTest.scala6
-rw-r--r--main/test/src/mill/main/JavaCompileJarTests.scala15
-rw-r--r--main/test/src/mill/util/ScriptTestSuite.scala19
-rw-r--r--main/test/src/mill/util/TestEvaluator.scala3
-rw-r--r--main/test/src/mill/util/TestUtil.scala9
16 files changed, 64 insertions, 76 deletions
diff --git a/main/test/src/mill/UTestFramework.scala b/main/test/src/mill/UTestFramework.scala
index 6c0d5191..c234151b 100644
--- a/main/test/src/mill/UTestFramework.scala
+++ b/main/test/src/mill/UTestFramework.scala
@@ -5,7 +5,7 @@ class UTestFramework extends utest.runner.Framework {
s.getClassName.startsWith("mill.")
}
override def setup() = {
- import ammonite.ops._
- rm(pwd / 'target / 'workspace)
+
+ os.remove.all(os.pwd / 'target / 'workspace)
}
}
diff --git a/main/test/src/mill/define/BasePathTests.scala b/main/test/src/mill/define/BasePathTests.scala
index d5167081..b8a653c8 100644
--- a/main/test/src/mill/define/BasePathTests.scala
+++ b/main/test/src/mill/define/BasePathTests.scala
@@ -2,7 +2,6 @@ package mill.define
import mill.util.{TestGraphs, TestUtil}
import utest._
-import ammonite.ops._
import mill.{Module, T}
object BasePathTests extends TestSuite{
val testGraphs = new TestGraphs
@@ -54,7 +53,7 @@ object BasePathTests extends TestSuite{
}
'overriden - {
object overridenBasePath extends TestUtil.BaseModule {
- override def millSourcePath = pwd / 'overridenBasePathRootValue
+ override def millSourcePath = os.pwd / 'overridenBasePathRootValue
object nested extends Module{
override def millSourcePath = super.millSourcePath / 'overridenBasePathNested
object nested extends Module{
@@ -63,9 +62,9 @@ object BasePathTests extends TestSuite{
}
}
assert(
- overridenBasePath.millSourcePath == pwd / 'overridenBasePathRootValue,
- overridenBasePath.nested.millSourcePath == pwd / 'overridenBasePathRootValue / 'nested / 'overridenBasePathNested,
- overridenBasePath.nested.nested.millSourcePath == pwd / 'overridenBasePathRootValue / 'nested / 'overridenBasePathNested / 'nested / 'overridenBasePathDoubleNested
+ overridenBasePath.millSourcePath == os.pwd / 'overridenBasePathRootValue,
+ overridenBasePath.nested.millSourcePath == os.pwd / 'overridenBasePathRootValue / 'nested / 'overridenBasePathNested,
+ overridenBasePath.nested.nested.millSourcePath == os.pwd / 'overridenBasePathRootValue / 'nested / 'overridenBasePathNested / 'nested / 'overridenBasePathDoubleNested
)
}
diff --git a/main/test/src/mill/define/CacherTests.scala b/main/test/src/mill/define/CacherTests.scala
index 98f2b7f8..84a8d840 100644
--- a/main/test/src/mill/define/CacherTests.scala
+++ b/main/test/src/mill/define/CacherTests.scala
@@ -1,6 +1,5 @@
package mill.define
-import ammonite.ops.pwd
import mill.util.{DummyLogger, TestEvaluator, TestUtil}
import mill.util.Strict.Agg
import mill.T
diff --git a/main/test/src/mill/eval/CrossTests.scala b/main/test/src/mill/eval/CrossTests.scala
index 3dec0222..f194924e 100644
--- a/main/test/src/mill/eval/CrossTests.scala
+++ b/main/test/src/mill/eval/CrossTests.scala
@@ -1,6 +1,6 @@
package mill.eval
-import ammonite.ops._
+
import mill.define.Discover
import mill.util.TestEvaluator
diff --git a/main/test/src/mill/eval/EvaluationTests.scala b/main/test/src/mill/eval/EvaluationTests.scala
index 75a5bbe3..74f9088c 100644
--- a/main/test/src/mill/eval/EvaluationTests.scala
+++ b/main/test/src/mill/eval/EvaluationTests.scala
@@ -9,7 +9,7 @@ import mill.util.Strict.Agg
import utest._
import utest.framework.TestPath
-import ammonite.ops._
+
object EvaluationTests extends TestSuite{
class Checker[T <: TestUtil.BaseModule](module: T)(implicit tp: TestPath) {
diff --git a/main/test/src/mill/eval/FailureTests.scala b/main/test/src/mill/eval/FailureTests.scala
index 22021079..bf45119c 100644
--- a/main/test/src/mill/eval/FailureTests.scala
+++ b/main/test/src/mill/eval/FailureTests.scala
@@ -1,7 +1,6 @@
package mill.eval
import mill.T
import mill.util.{TestEvaluator, TestUtil}
-import ammonite.ops.{Path, pwd, rm}
import mill.eval.Result.OuterStack
import utest._
import utest.framework.TestPath
diff --git a/main/test/src/mill/eval/JavaCompileJarTests.scala b/main/test/src/mill/eval/JavaCompileJarTests.scala
index d4bdbd87..8e931747 100644
--- a/main/test/src/mill/eval/JavaCompileJarTests.scala
+++ b/main/test/src/mill/eval/JavaCompileJarTests.scala
@@ -1,7 +1,5 @@
package mill.eval
-import ammonite.ops.ImplicitWd._
-import ammonite.ops._
import mill.define.{Discover, Input, Target, Task}
import mill.modules.Jvm
import mill.util.Ctx.Dest
@@ -12,19 +10,19 @@ import utest._
import mill._
object JavaCompileJarTests extends TestSuite{
def compileAll(sources: mill.util.Loose.Agg[PathRef])(implicit ctx: Dest) = {
- mkdir(ctx.dest)
- import ammonite.ops._
- %("javac", sources.map(_.path.toString()).toSeq, "-d", ctx.dest)(wd = ctx.dest)
+ os.makeDir.all(ctx.dest)
+
+ os.proc("javac", sources.map(_.path.toString()).toSeq, "-d", ctx.dest).call(ctx.dest)
PathRef(ctx.dest)
}
val tests = Tests{
'javac {
- val javacSrcPath = pwd / 'main / 'test / 'resources / 'examples / 'javac
+ val javacSrcPath = os.pwd / 'main / 'test / 'resources / 'examples / 'javac
val javacDestPath = TestUtil.getOutPath() / 'src
- mkdir(javacDestPath / up)
- cp(javacSrcPath, javacDestPath)
+ os.makeDir.all(javacDestPath / os.up)
+ os.copy(javacSrcPath, javacDestPath)
object Build extends TestUtil.BaseModule{
def sourceRootPath = javacDestPath / 'src
@@ -36,14 +34,14 @@ object JavaCompileJarTests extends TestSuite{
// resourceRoot ----> jar
def sourceRoot = T.sources{ sourceRootPath }
def resourceRoot = T.sources{ resourceRootPath }
- def allSources = T{ sourceRoot().flatMap(p => ls.rec(p.path)).map(PathRef(_)) }
+ def allSources = T{ sourceRoot().flatMap(p => os.walk(p.path)).map(PathRef(_)) }
def classFiles = T{ compileAll(allSources()) }
def jar = T{ Jvm.createJar(Loose.Agg(classFiles().path) ++ resourceRoot().map(_.path)) }
// Test createJar() with optional file filter.
- def filterJar(fileFilter: (Path, RelPath) => Boolean) = T{ Jvm.createJar(Loose.Agg(classFiles().path) ++ resourceRoot().map(_.path), None, fileFilter) }
+ def filterJar(fileFilter: (os.Path, os.RelPath) => Boolean) = T{ Jvm.createJar(Loose.Agg(classFiles().path) ++ resourceRoot().map(_.path), None, fileFilter) }
def run(mainClsName: String) = T.command{
- %%('java, "-Duser.language=en", "-cp", classFiles().path, mainClsName)
+ os.proc('java, "-Duser.language=en", "-cp", classFiles().path, mainClsName).call()
}
}
@@ -57,7 +55,7 @@ object JavaCompileJarTests extends TestSuite{
evaluator.check(targets, expected)
}
- def append(path: Path, txt: String) = ammonite.ops.write.append(path, txt)
+ def append(path: os.Path, txt: String) = ammonite.ops.write.append(path, txt)
check(
@@ -67,7 +65,6 @@ object JavaCompileJarTests extends TestSuite{
// Re-running with no changes results in nothing being evaluated
check(targets = Agg(jar), expected = Agg())
-
// Appending an empty string gets ignored due to file-content hashing
append(sourceRootPath / "Foo.java", "")
check(targets = Agg(jar), expected = Agg())
@@ -106,7 +103,7 @@ object JavaCompileJarTests extends TestSuite{
check(targets = Agg(allSources), expected = Agg(allSources))
check(targets = Agg(jar), expected = Agg(classFiles, jar))
- val jarContents = %%('jar, "-tf", evaluator.outPath/'jar/'dest/"out.jar")(evaluator.outPath).out.string
+ val jarContents = os.proc('jar, "-tf", evaluator.outPath/'jar/'dest/"out.jar").call(evaluator.outPath).out.string
val expectedJarContents =
"""META-INF/MANIFEST.MF
|test/Bar.class
@@ -116,16 +113,16 @@ object JavaCompileJarTests extends TestSuite{
|test/FooTwo.class
|hello.txt
|""".stripMargin
- assert(jarContents.lines.toSeq == expectedJarContents.lines.toSeq)
+ assert(jarContents.linesIterator.toSeq == expectedJarContents.linesIterator.toSeq)
// Create the Jar again, but this time, filter out the Foo files.
def noFoos(s: String) = !s.contains("Foo")
- val filterFunc = (p: Path, r: RelPath) => noFoos(r.last)
+ val filterFunc = (p: os.Path, r: os.RelPath) => noFoos(r.last)
eval(filterJar(filterFunc))
- val filteredJarContents = %%('jar, "-tf", evaluator.outPath/'filterJar/'dest/"out.jar")(evaluator.outPath).out.string
- assert(filteredJarContents.lines.toSeq == expectedJarContents.lines.filter(noFoos(_)).toSeq)
+ val filteredJarContents = os.proc('jar, "-tf", evaluator.outPath/'filterJar/'dest/"out.jar").call(evaluator.outPath).out.string
+ assert(filteredJarContents.linesIterator.toSeq == expectedJarContents.linesIterator.filter(noFoos(_)).toSeq)
- val executed = %%('java, "-cp", evaluator.outPath/'jar/'dest/"out.jar", "test.Foo")(evaluator.outPath).out.string
+ val executed = os.proc('java, "-cp", evaluator.outPath/'jar/'dest/"out.jar", "test.Foo").call(evaluator.outPath).out.string
assert(executed == (31337 + 271828) + System.lineSeparator)
for(i <- 0 until 3){
diff --git a/main/test/src/mill/eval/ModuleTests.scala b/main/test/src/mill/eval/ModuleTests.scala
index 0b4a7c80..f28fc9b6 100644
--- a/main/test/src/mill/eval/ModuleTests.scala
+++ b/main/test/src/mill/eval/ModuleTests.scala
@@ -1,6 +1,6 @@
package mill.eval
-import ammonite.ops._
+
import mill.util.{TestEvaluator, TestUtil}
import mill.T
import mill.define.Discover
@@ -19,15 +19,15 @@ object ModuleTests extends TestSuite{
def z = T{ ExternalModule.x() + ExternalModule.inner.y() }
}
val tests = Tests {
- rm(TestEvaluator.externalOutPath)
+ os.remove.all(TestEvaluator.externalOutPath)
'externalModuleTargetsAreNamespacedByModulePackagePath - {
val check = new TestEvaluator(Build)
val zresult = check.apply(Build.z)
assert(
zresult == Right((30, 1)),
- read(check.evaluator.outPath / 'z / "meta.json").contains("30"),
- read(TestEvaluator.externalOutPath / 'mill / 'eval / 'ModuleTests / 'ExternalModule / 'x / "meta.json").contains("13"),
- read(TestEvaluator.externalOutPath / 'mill / 'eval / 'ModuleTests / 'ExternalModule / 'inner / 'y / "meta.json").contains("17")
+ os.read(check.evaluator.outPath / 'z / "meta.json").contains("30"),
+ os.read(TestEvaluator.externalOutPath / 'mill / 'eval / 'ModuleTests / 'ExternalModule / 'x / "meta.json").contains("13"),
+ os.read(TestEvaluator.externalOutPath / 'mill / 'eval / 'ModuleTests / 'ExternalModule / 'inner / 'y / "meta.json").contains("17")
)
}
'externalModuleMustBeGlobalStatic - {
diff --git a/main/test/src/mill/eval/TaskTests.scala b/main/test/src/mill/eval/TaskTests.scala
index 4ba65e17..0bfd8efc 100644
--- a/main/test/src/mill/eval/TaskTests.scala
+++ b/main/test/src/mill/eval/TaskTests.scala
@@ -1,7 +1,7 @@
package mill.eval
import utest._
-import ammonite.ops._
+
import mill.T
import mill.util.TestEvaluator
@@ -34,15 +34,15 @@ object TaskTests extends TestSuite{
def persistent = T.persistent{
input() // force re-computation
- mkdir(T.ctx().dest)
- write.append(T.ctx().dest/'count, "hello\n")
- read.lines(T.ctx().dest/'count).length
+ os.makeDir.all(T.ctx().dest)
+ os.write.append(T.ctx().dest/'count, "hello\n")
+ os.read.lines(T.ctx().dest/'count).length
}
def nonPersistent = T{
input() // force re-computation
- mkdir(T.ctx().dest)
- write.append(T.ctx().dest/'count, "hello\n")
- read.lines(T.ctx().dest/'count).length
+ os.makeDir.all(T.ctx().dest)
+ os.write.append(T.ctx().dest/'count, "hello\n")
+ os.read.lines(T.ctx().dest/'count).length
}
def staticWorkerDownstream = T{
diff --git a/main/test/src/mill/main/ClientServerTests.scala b/main/test/src/mill/main/ClientServerTests.scala
index 2462f650..05238a5f 100644
--- a/main/test/src/mill/main/ClientServerTests.scala
+++ b/main/test/src/mill/main/ClientServerTests.scala
@@ -1,6 +1,5 @@
package mill.main
import java.io._
-import java.nio.file.Path
import mill.main.client.{Util, Locks}
@@ -47,7 +46,7 @@ object ClientServerTests extends TestSuite{
(tmpDir, locks)
}
- def spawnEchoServer(tmpDir : Path, locks: Locks): Unit = {
+ def spawnEchoServer(tmpDir : java.nio.file.Path, locks: Locks): Unit = {
new Thread(() => new Server(
tmpDir.toString,
new EchoServer(),
@@ -57,7 +56,7 @@ object ClientServerTests extends TestSuite{
).run()).start()
}
- def runClientAux(tmpDir : Path, locks: Locks)
+ def runClientAux(tmpDir : java.nio.file.Path, locks: Locks)
(env : Map[String, String], args: Array[String]) = {
val (in, out, err) = initStreams()
Server.lockBlock(locks.clientLock){
diff --git a/main/test/src/mill/main/ForeignBuildsTest.scala b/main/test/src/mill/main/ForeignBuildsTest.scala
index 085ada02..cfc8d00c 100644
--- a/main/test/src/mill/main/ForeignBuildsTest.scala
+++ b/main/test/src/mill/main/ForeignBuildsTest.scala
@@ -1,14 +1,13 @@
package mill.main
-import ammonite.ops._
import mill.util.ScriptTestSuite
import utest._
object ForeignBuildsTest extends ScriptTestSuite(fork = false) {
def workspaceSlug = "foreign-builds"
def scriptSourcePath =
- pwd / 'main / 'test / 'resources / 'examples / 'foreign
- override def buildPath = 'project / "build.sc"
+ os.pwd / 'main / 'test / 'resources / 'examples / 'foreign
+ override def buildPath = os.rel / 'project / "build.sc"
val tests = Tests {
initWorkspace()
diff --git a/main/test/src/mill/main/ForeignConflictTest.scala b/main/test/src/mill/main/ForeignConflictTest.scala
index c5d99c9f..a4352bb6 100644
--- a/main/test/src/mill/main/ForeignConflictTest.scala
+++ b/main/test/src/mill/main/ForeignConflictTest.scala
@@ -1,14 +1,14 @@
package mill.main
-import ammonite.ops._
+
import mill.util.ScriptTestSuite
import utest._
object ForeignConflictTest extends ScriptTestSuite(fork = false) {
def workspaceSlug = "foreign-conflict"
def scriptSourcePath =
- pwd / 'main / 'test / 'resources / 'examples / 'foreign
- override def buildPath = 'conflict / "build.sc"
+ os.pwd / 'main / 'test / 'resources / 'examples / 'foreign
+ override def buildPath = os.rel / 'conflict / "build.sc"
val tests = Tests {
initWorkspace()
diff --git a/main/test/src/mill/main/JavaCompileJarTests.scala b/main/test/src/mill/main/JavaCompileJarTests.scala
index 6c45b454..37c64b05 100644
--- a/main/test/src/mill/main/JavaCompileJarTests.scala
+++ b/main/test/src/mill/main/JavaCompileJarTests.scala
@@ -1,12 +1,11 @@
package mill.main
-import ammonite.ops._
import mill.util.ScriptTestSuite
import utest._
object JavaCompileJarTests extends ScriptTestSuite(fork = false) {
def workspaceSlug = "java-compile-jar"
- def scriptSourcePath = pwd / 'main / 'test / 'resources / 'examples / 'javac
+ def scriptSourcePath = os.pwd / 'main / 'test / 'resources / 'examples / 'javac
val tests = Tests{
initWorkspace()
'test - {
@@ -31,8 +30,8 @@ object JavaCompileJarTests extends ScriptTestSuite(fork = false) {
)
// If we update resources, classFiles are unchanged but jar changes
- for(scalaFile <- ls.rec(workspacePath).filter(_.ext == "txt")){
- write.append(scalaFile, "\n")
+ for(scalaFile <- os.walk(workspacePath).filter(_.ext == "txt")){
+ os.write.append(scalaFile, "\n")
}
assert(eval("classFiles"))
@@ -48,15 +47,15 @@ object JavaCompileJarTests extends ScriptTestSuite(fork = false) {
// We can intentionally break the code, have the targets break, then
// fix the code and have them recover.
- for(scalaFile <- ls.rec(workspacePath).filter(_.ext == "java")){
- write.append(scalaFile, "\n}")
+ for(scalaFile <- os.walk(workspacePath).filter(_.ext == "java")){
+ os.write.append(scalaFile, "\n}")
}
assert(!eval("classFiles"))
assert(!eval("jar"))
- for(scalaFile <- ls.rec(workspacePath).filter(_.ext == "java")){
- write.over(scalaFile, read(scalaFile).dropRight(2))
+ for(scalaFile <- os.walk(workspacePath).filter(_.ext == "java")){
+ os.write.over(scalaFile, os.read(scalaFile).dropRight(2))
}
assert(eval("classFiles"))
diff --git a/main/test/src/mill/util/ScriptTestSuite.scala b/main/test/src/mill/util/ScriptTestSuite.scala
index 9d3edb65..b324f94c 100644
--- a/main/test/src/mill/util/ScriptTestSuite.scala
+++ b/main/test/src/mill/util/ScriptTestSuite.scala
@@ -2,16 +2,15 @@ package mill.util
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, PrintStream}
-import ammonite.ops._
import utest._
abstract class ScriptTestSuite(fork: Boolean) extends TestSuite{
def workspaceSlug: String
- def scriptSourcePath: Path
- def buildPath: RelPath = "build.sc"
+ def scriptSourcePath: os.Path
+ def buildPath: os.RelPath = "build.sc"
- val workspacePath = pwd / 'target / 'workspace / workspaceSlug
- val wd = workspacePath / buildPath / up
+ val workspacePath = os.pwd / 'target / 'workspace / workspaceSlug
+ val wd = workspacePath / buildPath / os.up
val stdOutErr = new PrintStream(new ByteArrayOutputStream())
val stdIn = new ByteArrayInputStream(Array())
val disableTicker = false
@@ -25,7 +24,7 @@ abstract class ScriptTestSuite(fork: Boolean) extends TestSuite{
if (!fork) runner.runScript(workspacePath / buildPath , s.toList)
else{
try {
- %(home / "mill-release", "-i", s)(wd)
+ os.proc(os.home / "mill-release", "-i", s).call(wd)
true
}catch{case e: Throwable => false}
}
@@ -33,17 +32,17 @@ abstract class ScriptTestSuite(fork: Boolean) extends TestSuite{
def meta(s: String) = {
val (List(selector), args) = ParseArgs.apply(Seq(s), multiSelect = false).right.get
- read(wd / "out" / selector._2.value.flatMap(_.pathSegments) / "meta.json")
+ os.read(wd / "out" / selector._2.value.flatMap(_.pathSegments) / "meta.json")
}
def initWorkspace() = {
- rm(workspacePath)
- mkdir(workspacePath / up)
+ os.remove.all(workspacePath)
+ os.makeDir.all(workspacePath / os.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.
- cp(scriptSourcePath, workspacePath)
+ os.copy(scriptSourcePath, workspacePath)
}
}
diff --git a/main/test/src/mill/util/TestEvaluator.scala b/main/test/src/mill/util/TestEvaluator.scala
index 6e7fe484..67ba96dc 100644
--- a/main/test/src/mill/util/TestEvaluator.scala
+++ b/main/test/src/mill/util/TestEvaluator.scala
@@ -1,6 +1,5 @@
package mill.util
-import ammonite.ops.pwd
import mill.define.{Input, Target, Task}
import mill.eval.Result.OuterStack
import mill.eval.{Evaluator, Result}
@@ -10,7 +9,7 @@ import utest.framework.TestPath
import language.experimental.macros
object TestEvaluator{
- val externalOutPath = pwd / 'target / 'external
+ val externalOutPath = os.pwd / 'target / 'external
def static(module: TestUtil.BaseModule)(implicit fullName: sourcecode.FullName) = {
diff --git a/main/test/src/mill/util/TestUtil.scala b/main/test/src/mill/util/TestUtil.scala
index b4e3af89..e5fe906e 100644
--- a/main/test/src/mill/util/TestUtil.scala
+++ b/main/test/src/mill/util/TestUtil.scala
@@ -1,7 +1,6 @@
package mill.util
import mill.util.Router.Overrides
-import ammonite.ops.pwd
import mill.define._
import mill.eval.Result
import mill.eval.Result.OuterStack
@@ -14,17 +13,17 @@ import scala.collection.mutable
object TestUtil {
def getOutPath()(implicit fullName: sourcecode.FullName,
tp: TestPath) = {
- pwd / 'target / 'workspace / (fullName.value.split('.') ++ tp.value)
+ os.pwd / 'target / 'workspace / (fullName.value.split('.') ++ tp.value)
}
def getOutPathStatic()(implicit fullName: sourcecode.FullName) = {
- pwd / 'target / 'workspace / fullName.value.split('.')
+ os.pwd / 'target / 'workspace / fullName.value.split('.')
}
def getSrcPathStatic()(implicit fullName: sourcecode.FullName) = {
- pwd / 'target / 'worksources / fullName.value.split('.')
+ os.pwd / 'target / 'worksources / fullName.value.split('.')
}
def getSrcPathBase() = {
- pwd / 'target / 'worksources
+ os.pwd / 'target / 'worksources
}
class BaseModule(implicit millModuleEnclosing0: sourcecode.Enclosing,