diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-10-29 06:14:55 -0700 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-10-29 06:14:55 -0700 |
commit | b537a23436549fc8dbadbdca2714487933516b02 (patch) | |
tree | fc34e49a48ffcf54eeab2411d0dc1326d1fd485d /src/test/scala | |
parent | d1a8e26b0b747885782d261d17dbb1ce8d53a36b (diff) | |
download | mill-b537a23436549fc8dbadbdca2714487933516b02.tar.gz mill-b537a23436549fc8dbadbdca2714487933516b02.tar.bz2 mill-b537a23436549fc8dbadbdca2714487933516b02.zip |
Swap over wholesale to ammonite.ops
Diffstat (limited to 'src/test/scala')
-rw-r--r-- | src/test/scala/forge/EvaluationTests.scala | 3 | ||||
-rw-r--r-- | src/test/scala/forge/Main.scala | 34 |
2 files changed, 18 insertions, 19 deletions
diff --git a/src/test/scala/forge/EvaluationTests.scala b/src/test/scala/forge/EvaluationTests.scala index b9318c43..2fde2ce0 100644 --- a/src/test/scala/forge/EvaluationTests.scala +++ b/src/test/scala/forge/EvaluationTests.scala @@ -1,6 +1,5 @@ package forge -import java.nio.{file => jnio} import utest._ import utest.framework.TestPath @@ -13,7 +12,7 @@ object EvaluationTests extends TestSuite{ 'evaluateSingle - { class Checker[T: Discovered](base: T)(implicit tp: TestPath) { - val workspace = jnio.Paths.get("target/workspace", tp.value.mkString("/")) + val workspace = ammonite.ops.pwd / 'target / 'workspace / tp.value ammonite.ops.rm(ammonite.ops.Path(workspace, ammonite.ops.pwd)) // Make sure data is persisted even if we re-create the evaluator each time def evaluator = new Evaluator( diff --git a/src/test/scala/forge/Main.scala b/src/test/scala/forge/Main.scala index b65099ec..e4e38b23 100644 --- a/src/test/scala/forge/Main.scala +++ b/src/test/scala/forge/Main.scala @@ -1,53 +1,53 @@ package forge import java.io.FileOutputStream -import java.nio.{file => jnio} import java.util.jar.JarEntry import collection.JavaConverters._ +import ammonite.ops._ object Main{ def main(args: Array[String]): Unit = { - val sourceRoot = Target.path(jnio.Paths.get("src/test/resources/example/src")) - val resourceRoot = Target.path(jnio.Paths.get("src/test/resources/example/resources")) + val sourceRoot = Target.path(pwd / 'src / 'test / 'resources / 'example / 'src) + val resourceRoot = Target.path(pwd / 'src / 'test / 'resources / 'example / 'resources) val allSources = list(sourceRoot) val classFiles = compileAll(allSources) val jar = jarUp(resourceRoot, classFiles) // val evaluator = new Evaluator( -// jnio.Paths.get("target/workspace"), +// Paths.get("target/workspace"), // DefCtx("forge.Main ", None) // ) // evaluator.evaluate(OSet(jar)) } - def compileAll(sources: Target[Seq[jnio.Path]]) = { + def compileAll(sources: Target[Seq[Path]]) = { new Target.Subprocess( Seq(sources), args => Seq("javac") ++ - args[Seq[jnio.Path]](0).map(_.toAbsolutePath.toString) ++ - Seq("-d", args.dest.toAbsolutePath.toString) + args[Seq[Path]](0).map(_.toString) ++ + Seq("-d", args.dest.toString) ).map(_.dest) } - def list(root: Target[jnio.Path]): Target[Seq[jnio.Path]] = { - root.map(jnio.Files.list(_).iterator().asScala.toArray[jnio.Path]) + def list(root: Target[Path]): Target[Seq[Path]] = { + root.map(ls.rec) } - case class jarUp(roots: Target[jnio.Path]*) extends Target[jnio.Path]{ + case class jarUp(roots: Target[Path]*) extends Target[Path]{ val inputs = roots - def evaluate(args: Args): jnio.Path = { + def evaluate(args: Args): Path = { - val output = new java.util.jar.JarOutputStream(new FileOutputStream(args.dest.toFile)) + val output = new java.util.jar.JarOutputStream(new FileOutputStream(args.dest.toIO)) for{ root0 <- args.args - root = root0.asInstanceOf[jnio.Path] + root = root0.asInstanceOf[Path] - path <- jnio.Files.walk(root).iterator().asScala - if jnio.Files.isRegularFile(path) + path <- ls.rec(root) + if path.isFile }{ - val relative = root.relativize(path) + val relative = path.relativeTo(root) output.putNextEntry(new JarEntry(relative.toString)) - output.write(jnio.Files.readAllBytes(path)) + output.write(read.bytes(path)) } output.close() args.dest |