diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-11-05 03:00:04 +0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-11-05 21:14:58 +0800 |
commit | bc9dc386625021fec517f2dbf0644ccafe1e32c2 (patch) | |
tree | 12db6817470708c7aa274aa231ef35eb79f2123a /contrib/tut | |
parent | 8afe79afe33be68f59f89b8410984e508c3e8d08 (diff) | |
download | mill-bc9dc386625021fec517f2dbf0644ccafe1e32c2.tar.gz mill-bc9dc386625021fec517f2dbf0644ccafe1e32c2.tar.bz2 mill-bc9dc386625021fec517f2dbf0644ccafe1e32c2.zip |
WIP migrating over from `ammonite.ops` to `os` module.
__.compile works, haven't run tests yet
Diffstat (limited to 'contrib/tut')
-rw-r--r-- | contrib/tut/src/mill/contrib/tut/TutModule.scala | 9 | ||||
-rw-r--r-- | contrib/tut/test/src/mill/contrib/tut/TutTests.scala | 29 |
2 files changed, 18 insertions, 20 deletions
diff --git a/contrib/tut/src/mill/contrib/tut/TutModule.scala b/contrib/tut/src/mill/contrib/tut/TutModule.scala index f051a465..e51a8d7b 100644 --- a/contrib/tut/src/mill/contrib/tut/TutModule.scala +++ b/contrib/tut/src/mill/contrib/tut/TutModule.scala @@ -1,7 +1,6 @@ package mill package contrib.tut -import ammonite.ops._ import coursier.MavenRepository import mill.scalalib._ import scala.util.matching.Regex @@ -51,7 +50,7 @@ trait TutModule extends ScalaModule { * A task which determines where the compiled documentation files will be placed. By default this is simply the Mill build's output folder for this task, * but this can be reconfigured so that documentation goes to the root of the module (e.g. `millSourcePath`) or to a dedicated folder (e.g. `millSourcePath / 'docs`) */ - def tutTargetDirectory: T[Path] = T { T.ctx().dest } + def tutTargetDirectory: T[os.Path] = T { T.ctx().dest } /** * A task which determines what classpath is used when compiling documentation. By default this is configured to use the same inputs as the [[mill.contrib.tut.TutModule#runClasspath]], @@ -115,18 +114,18 @@ trait TutModule extends ScalaModule { /** * Run Tut using the configuration specified in this module. The working directory used is the [[mill.contrib.tut.TutModule#millSourcePath]]. */ - def tut: T[CommandResult] = T { + def tut: T[os.CommandResult] = T { val in = tutSourceDirectory().head.path.toIO.getAbsolutePath val out = tutTargetDirectory().toIO.getAbsolutePath val re = tutNameFilter() val opts = tutScalacOptions() val pOpts = tutPluginJars().map(pathRef => "-Xplugin:" + pathRef.path.toIO.getAbsolutePath) val tutArgs = List(in, out, re.pattern.toString) ++ opts ++ pOpts - %%( + os.proc( 'java, "-cp", tutClasspath().map(_.path.toIO.getAbsolutePath).mkString(java.io.File.pathSeparator), "tut.TutMain", tutArgs - )(wd = millSourcePath) + ).call(millSourcePath) } } diff --git a/contrib/tut/test/src/mill/contrib/tut/TutTests.scala b/contrib/tut/test/src/mill/contrib/tut/TutTests.scala index fd369eed..8168930f 100644 --- a/contrib/tut/test/src/mill/contrib/tut/TutTests.scala +++ b/contrib/tut/test/src/mill/contrib/tut/TutTests.scala @@ -1,7 +1,6 @@ package mill.contrib package tut -import ammonite.ops._ import mill._ import mill.eval.Result._ import mill.scalalib._ @@ -29,17 +28,17 @@ object TutTests extends TestSuite { def scalacPluginIvyDeps = Agg(ivy"org.spire-math::kind-projector:0.9.8") } - val resourcePath = pwd / 'contrib / 'tut / 'test / 'tut - val resourcePathWithLibraries = pwd / 'contrib / 'tut / 'test / "tut-with-libraries" + val resourcePath = os.pwd / 'contrib / 'tut / 'test / 'tut + val resourcePathWithLibraries = os.pwd / 'contrib / 'tut / 'test / "tut-with-libraries" - def workspaceTest[T](m: TestUtil.BaseModule, resourcePath: Path = resourcePath) + def workspaceTest[T](m: TestUtil.BaseModule, resourcePath: os.Path = resourcePath) (t: TestEvaluator => T) (implicit tp: TestPath): T = { val eval = new TestEvaluator(m) - rm(m.millSourcePath) - rm(eval.outPath) - mkdir(m.millSourcePath) - cp(resourcePath, m.millSourcePath / 'tut) + os.remove.all(m.millSourcePath) + os.remove.all(eval.outPath) + os.makeDir.all(m.millSourcePath) + os.copy(resourcePath, m.millSourcePath / 'tut) t(eval) } @@ -61,8 +60,8 @@ object TutTests extends TestSuite { val Right((result, evalCount)) = eval.apply(TutTest.tut) assert( - exists(expectedPath) && - read! expectedPath == expected + os.exists(expectedPath) && + os.read(expectedPath) == expected ) } @@ -84,9 +83,9 @@ object TutTests extends TestSuite { val Right((result, evalCount)) = eval.apply(TutCustomTest.tut) assert( - !exists(defaultPath) && - exists(expectedPath) && - read! expectedPath == expected + !os.exists(defaultPath) && + os.exists(expectedPath) && + os.read(expectedPath) == expected ) } @@ -115,8 +114,8 @@ object TutTests extends TestSuite { val Right(_) = eval.apply(TutLibrariesTest.tut) assert( - exists(expectedPath) && - read! expectedPath == expected + os.exists(expectedPath) && + os.read(expectedPath) == expected ) } } |