summaryrefslogtreecommitdiff
path: root/main/test/src/mill/eval
diff options
context:
space:
mode:
Diffstat (limited to 'main/test/src/mill/eval')
-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
6 files changed, 30 insertions, 34 deletions
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{