diff options
Diffstat (limited to 'main/test')
23 files changed, 87 insertions, 106 deletions
diff --git a/main/test/resources/examples/foreign/conflict/build.sc b/main/test/resources/examples/foreign/conflict/build.sc index d6c08b81..bedd7237 100644 --- a/main/test/resources/examples/foreign/conflict/build.sc +++ b/main/test/resources/examples/foreign/conflict/build.sc @@ -1,6 +1,5 @@ import $file.inner.{build => innerBuild} import mill._ -import ammonite.ops._ // In this build, we have a local module targeting // the 'inner sub-directory, and an imported foreign @@ -20,5 +19,5 @@ def checkDests : T[Unit] = T { } object inner extends mill.Module { - def selfDest = T { T.ctx().dest / up / up } + def selfDest = T { T.ctx().dest / os.up / os.up } } diff --git a/main/test/resources/examples/foreign/conflict/inner/build.sc b/main/test/resources/examples/foreign/conflict/inner/build.sc index 729f4f3d..81e5fc2f 100644 --- a/main/test/resources/examples/foreign/conflict/inner/build.sc +++ b/main/test/resources/examples/foreign/conflict/inner/build.sc @@ -1,4 +1,3 @@ import mill._ -import ammonite.ops._ -def selfDest = T { T.ctx().dest / up / up } +def selfDest = T { T.ctx().dest / os.up / os.up } diff --git a/main/test/resources/examples/foreign/outer/build.sc b/main/test/resources/examples/foreign/outer/build.sc index b53cca70..adef19da 100644 --- a/main/test/resources/examples/foreign/outer/build.sc +++ b/main/test/resources/examples/foreign/outer/build.sc @@ -1,13 +1,12 @@ import $file.inner.build import mill._ -import ammonite.ops._ trait PathAware extends mill.Module { def selfPath = T { millSourcePath } } trait DestAware extends mill.Module { - def selfDest = T { T.ctx().dest / up / up } + def selfDest = T { T.ctx().dest / os.up / os.up } } object sub extends PathAware with DestAware { diff --git a/main/test/resources/examples/foreign/outer/inner/build.sc b/main/test/resources/examples/foreign/outer/inner/build.sc index 2d978292..da103b95 100644 --- a/main/test/resources/examples/foreign/outer/inner/build.sc +++ b/main/test/resources/examples/foreign/outer/inner/build.sc @@ -1,12 +1,11 @@ import mill._ -import ammonite.ops._ trait PathAware extends mill.Module { def selfPath = T { millSourcePath } } trait DestAware extends mill.Module { - def selfDest = T { T.ctx().dest / up / up } + def selfDest = T { T.ctx().dest / os.up / os.up } } object sub extends PathAware with DestAware { diff --git a/main/test/resources/examples/foreign/project/build.sc b/main/test/resources/examples/foreign/project/build.sc index 80c2af9b..54686c2d 100644 --- a/main/test/resources/examples/foreign/project/build.sc +++ b/main/test/resources/examples/foreign/project/build.sc @@ -1,10 +1,9 @@ import $file.^.outer.build import $file.inner.build -import ammonite.ops._ import mill._ -def assertPaths(p1 : Path, p2 : Path) : Unit = if (p1 != p2) throw new Exception( +def assertPaths(p1 : os.Path, p2 : os.Path) : Unit = if (p1 != p2) throw new Exception( s"Paths were not equal : \n- $p1 \n- $p2" ) @@ -17,7 +16,7 @@ object sub extends PathAware with DestAware { } def checkProjectPaths = T { - val thisPath : Path = millSourcePath + val thisPath : os.Path = millSourcePath assert(thisPath.last == "project") assertPaths(sub.selfPath(), thisPath / 'sub) assertPaths(sub.sub.selfPath(), thisPath / 'sub / 'sub) @@ -25,47 +24,47 @@ def checkProjectPaths = T { } def checkInnerPaths = T { - val thisPath : Path = millSourcePath + val thisPath : os.Path = millSourcePath assertPaths(inner.build.millSourcePath, thisPath / 'inner ) assertPaths(inner.build.sub.selfPath(), thisPath / 'inner / 'sub) assertPaths(inner.build.sub.sub.selfPath(), thisPath / 'inner / 'sub / 'sub) } def checkOuterPaths = T { - val thisPath : Path = millSourcePath - assertPaths(^.outer.build.millSourcePath, thisPath / up / 'outer ) - assertPaths(^.outer.build.sub.selfPath(), thisPath / up / 'outer / 'sub) - assertPaths(^.outer.build.sub.sub.selfPath(), thisPath / up / 'outer / 'sub / 'sub) + val thisPath : os.Path = millSourcePath + assertPaths(^.outer.build.millSourcePath, thisPath / os.up / 'outer ) + assertPaths(^.outer.build.sub.selfPath(), thisPath / os.up / 'outer / 'sub) + assertPaths(^.outer.build.sub.sub.selfPath(), thisPath / os.up / 'outer / 'sub / 'sub) } def checkOuterInnerPaths = T { - val thisPath : Path = millSourcePath - assertPaths(^.outer.inner.build.millSourcePath, thisPath / up / 'outer / 'inner ) - assertPaths(^.outer.inner.build.sub.selfPath(), thisPath / up / 'outer / 'inner /'sub) - assertPaths(^.outer.inner.build.sub.sub.selfPath(), thisPath / up / 'outer / 'inner / 'sub / 'sub) + val thisPath : os.Path = millSourcePath + assertPaths(^.outer.inner.build.millSourcePath, thisPath / os.up / 'outer / 'inner ) + assertPaths(^.outer.inner.build.sub.selfPath(), thisPath / os.up / 'outer / 'inner /'sub) + assertPaths(^.outer.inner.build.sub.sub.selfPath(), thisPath / os.up / 'outer / 'inner / 'sub / 'sub) } def checkProjectDests = T { - val outPath : Path = millSourcePath / 'out + val outPath : os.Path = millSourcePath / 'out assertPaths(sub.selfDest(), outPath / 'sub) assertPaths(sub.sub.selfDest(), outPath / 'sub / 'sub) assertPaths(sub.sub2.selfDest(), outPath / 'sub / 'sub2) } def checkInnerDests = T { - val foreignOut : Path = millSourcePath / 'out / "foreign-modules" + val foreignOut : os.Path = millSourcePath / 'out / "foreign-modules" assertPaths(inner.build.sub.selfDest(), foreignOut / 'inner / 'sub) assertPaths(inner.build.sub.sub.selfDest(), foreignOut / 'inner / 'sub / 'sub) } def checkOuterDests = T { - val foreignOut : Path = millSourcePath / 'out / "foreign-modules" + val foreignOut : os.Path = millSourcePath / 'out / "foreign-modules" assertPaths(^.outer.build.sub.selfDest(), foreignOut / "up-1" / 'outer/ 'sub ) assertPaths(^.outer.build.sub.sub.selfDest(), foreignOut / "up-1" / 'outer/ 'sub / 'sub) } def checkOuterInnerDests = T { - val foreignOut : Path = millSourcePath / 'out / "foreign-modules" + val foreignOut : os.Path = millSourcePath / 'out / "foreign-modules" assertPaths(^.outer.inner.build.sub.selfDest(), foreignOut / "up-1" / 'outer/ 'inner / 'sub) assertPaths(^.outer.inner.build.sub.sub.selfDest(), foreignOut / "up-1" / 'outer/ 'inner / 'sub / 'sub) } @@ -77,6 +76,6 @@ trait PathAware extends mill.Module { } trait DestAware extends mill.Module { - def selfDest = T { T.ctx().dest / up / up } + def selfDest = T { T.ctx().dest / os.up / os.up } } diff --git a/main/test/resources/examples/foreign/project/inner/build.sc b/main/test/resources/examples/foreign/project/inner/build.sc index 2d978292..da103b95 100644 --- a/main/test/resources/examples/foreign/project/inner/build.sc +++ b/main/test/resources/examples/foreign/project/inner/build.sc @@ -1,12 +1,11 @@ import mill._ -import ammonite.ops._ trait PathAware extends mill.Module { def selfPath = T { millSourcePath } } trait DestAware extends mill.Module { - def selfDest = T { T.ctx().dest / up / up } + def selfDest = T { T.ctx().dest / os.up / os.up } } object sub extends PathAware with DestAware { diff --git a/main/test/resources/examples/javac/build.sc b/main/test/resources/examples/javac/build.sc index 0783ac17..c45a6e2d 100644 --- a/main/test/resources/examples/javac/build.sc +++ b/main/test/resources/examples/javac/build.sc @@ -1,4 +1,3 @@ -import ammonite.ops._ import mill.T import mill.eval.JavaCompileJarTests.compileAll import mill.eval.PathRef @@ -14,10 +13,10 @@ def resourceRootPath = millSourcePath / 'resources // 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)) } def run(mainClsName: String) = T.command{ - %%('java, "-cp", classFiles().path, mainClsName)(T.ctx().dest) + os.proc('java, "-cp", classFiles().path, mainClsName).call(T.ctx().dest) } 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, |