summaryrefslogtreecommitdiff
path: root/integration
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-11-05 03:00:04 +0800
committerLi Haoyi <haoyi.sg@gmail.com>2018-11-05 21:14:58 +0800
commitbc9dc386625021fec517f2dbf0644ccafe1e32c2 (patch)
tree12db6817470708c7aa274aa231ef35eb79f2123a /integration
parent8afe79afe33be68f59f89b8410984e508c3e8d08 (diff)
downloadmill-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 'integration')
-rw-r--r--integration/test/resources/ammonite/build.sc4
-rw-r--r--integration/test/resources/jawn/build.sc5
-rw-r--r--integration/test/resources/play-json/build.sc36
-rw-r--r--integration/test/resources/play-json/headers.sc10
-rw-r--r--integration/test/resources/play-json/jmh.sc16
-rw-r--r--integration/test/resources/play-json/mima.sc4
-rw-r--r--integration/test/resources/play-json/reformat.sc12
-rwxr-xr-xintegration/test/resources/play-json/release.sh2
-rw-r--r--integration/test/resources/upickle/build.sc2
-rw-r--r--integration/test/src/mill/integration/AcyclicTests.scala9
-rw-r--r--integration/test/src/mill/integration/AmmoniteTests.scala5
-rw-r--r--integration/test/src/mill/integration/BetterFilesTests.scala5
-rw-r--r--integration/test/src/mill/integration/DocAnnotationsTests.scala3
-rw-r--r--integration/test/src/mill/integration/IntegrationTestSuite.scala11
-rw-r--r--integration/test/src/mill/integration/JawnTests.scala9
-rw-r--r--integration/test/src/mill/integration/PlayJsonTests.scala6
-rw-r--r--integration/test/src/mill/integration/UpickleTests.scala1
17 files changed, 68 insertions, 72 deletions
diff --git a/integration/test/resources/ammonite/build.sc b/integration/test/resources/ammonite/build.sc
index c26d5050..34f80825 100644
--- a/integration/test/resources/ammonite/build.sc
+++ b/integration/test/resources/ammonite/build.sc
@@ -65,8 +65,8 @@ object amm extends Cross[MainModule](fullCrossScalaVersions:_*){
)
def generatedSources = T{
- import ammonite.ops._
- cp(build.millSourcePath/'project/"Constants.scala", T.ctx().dest/"Constants.scala")
+
+ os.copy(build.millSourcePath/'project/"Constants.scala", T.ctx().dest/"Constants.scala")
Seq(PathRef(T.ctx().dest))
}
}
diff --git a/integration/test/resources/jawn/build.sc b/integration/test/resources/jawn/build.sc
index deb9731a..8b58efc7 100644
--- a/integration/test/resources/jawn/build.sc
+++ b/integration/test/resources/jawn/build.sc
@@ -1,10 +1,9 @@
import mill.scalalib
import mill.Cross
import mill.scalalib.{Dep, TestModule, DepSyntax, Lib}
-import ammonite.ops.up
object jawn extends Cross[JawnModule]("2.10.6", "2.11.11", "2.12.3")
class JawnModule(crossVersion: String) extends mill.Module{
- override def millSourcePath = super.millSourcePath / up / up
+ override def millSourcePath = super.millSourcePath / os.up / os.up
trait JawnModule extends scalalib.SbtModule{
def scalaVersion = crossVersion
@@ -53,7 +52,7 @@ class JawnModule(crossVersion: String) extends mill.Module{
object rojoma extends Support(ivy"com.rojoma::rojoma-json:2.4.3")
object rojomaV3 extends Support(ivy"com.rojoma::rojoma-json-v3:3.7.2"){
- override def millSourcePath = super.millSourcePath / up / "rojoma-v3"
+ override def millSourcePath = super.millSourcePath / os.up / "rojoma-v3"
}
object spray extends Support(ivy"io.spray::spray-json:1.3.3")
}
diff --git a/integration/test/resources/play-json/build.sc b/integration/test/resources/play-json/build.sc
index d4557011..54e63d65 100644
--- a/integration/test/resources/play-json/build.sc
+++ b/integration/test/resources/play-json/build.sc
@@ -10,7 +10,7 @@ import jmh.Jmh
import headers.Headers
import com.typesafe.tools.mima.core._
-import ammonite.ops._
+
import mill.define.Task
val ScalaVersions = Seq("2.10.7", "2.11.12", "2.12.4", "2.13.0-M3")
@@ -52,7 +52,7 @@ trait PlayJsonModule extends BaseModule with PublishModule with MiMa {
abstract class PlayJson(val platformSegment: String) extends PlayJsonModule {
def crossScalaVersion: String
- def millSourcePath = pwd / "play-json"
+ def millSourcePath = os.pwd / "play-json"
def artifactName = "play-json"
def sources = T.sources(
@@ -90,10 +90,10 @@ abstract class PlayJson(val platformSegment: String) extends PlayJsonModule {
)
def generatedSources = T {
- import ammonite.ops._
+
val dir = T.ctx().dest
- mkdir(dir / "play-json")
+ os.makeDir.all(dir / "play-json")
val file = dir / "play-json" / "Generated.scala"
val (writes, reads) = (1 to 22).map { i =>
@@ -126,7 +126,7 @@ abstract class PlayJson(val platformSegment: String) extends PlayJsonModule {
""")
}.unzip
- write(file, s"""
+ os.write(file, s"""
package play.api.libs.json
trait GeneratedReads {
@@ -168,7 +168,11 @@ class PlayJsonJvm(val crossScalaVersion: String) extends PlayJson("jvm") {
)
def sources = {
- val docSpecs = ls.rec(millSourcePath / up / "docs" / "manual" / "working" / "scalaGuide").filter(_.isDir).filter(_.last=="code").map(PathRef(_))
+ val docSpecs = os.walk(millSourcePath / os.up / "docs" / "manual" / "working" / "scalaGuide")
+ .filter(os.isDir)
+ .filter(_.last=="code")
+ .map(PathRef(_))
+
T.sources(
docSpecs ++
Seq(
@@ -213,7 +217,7 @@ class PlayJsonJs(val crossScalaVersion: String) extends PlayJson("js") with Scal
}
trait PlayFunctional extends PlayJsonModule {
- def millSourcePath = pwd / "play-functional"
+ def millSourcePath = os.pwd / "play-functional"
def artifactName = "play-functional"
}
@@ -229,7 +233,7 @@ object playJoda extends Cross[PlayJoda](ScalaVersions:_*)
class PlayJoda(val crossScalaVersion: String) extends PlayJsonModule {
def moduleDeps = Seq(playJsonJvm(crossScalaVersion))
- def millSourcePath = pwd / "play-json-joda"
+ def millSourcePath = os.pwd / "play-json-joda"
def artifactName = "play-json-joda"
def ivyDeps = Agg(
@@ -250,7 +254,7 @@ object benchmarks extends Cross[Benchmarks](ScalaVersions:_*)
class Benchmarks(val crossScalaVersion: String) extends BaseModule with Jmh {
def moduleDeps = Seq(playJsonJvm(crossScalaVersion))
- def millSourcePath = pwd / "benchmarks"
+ def millSourcePath = os.pwd / "benchmarks"
}
// TODO: we should have a way to "take all modules in this build"
@@ -322,7 +326,7 @@ def validateCode() = T.command {
*/
object release extends Module {
- implicit val wd = pwd
+ implicit val wd = os.pwd
val versionFile = wd / "version.sc"
@@ -345,27 +349,27 @@ object release extends Module {
def setReleaseVersion = T {
T.ctx.log.info(s"Setting release version to ${releaseVersion}")
- write.over(
+ os.write.over(
versionFile,
s"""def current = "${releaseVersion}"
|
""".stripMargin
)
- %%("git", "commit", "-am", s"Setting release version to ${releaseVersion}")
- %%("git", "tag", s"$releaseVersion")
+ os.proc("git", "commit", "-am", s"Setting release version to ${releaseVersion}").call()
+ os.proc("git", "tag", s"$releaseVersion").call()
}
def setNextVersion = T {
T.ctx.log.info(s"Setting next version to ${nextVersion}")
- write.over(
+ os.write.over(
versionFile,
s"""def current = "${nextVersion}""""
)
- %%("git", "commit", "-am", s"Setting next version to ${nextVersion}")
- %%("git", "push", "origin", "master", "--tags")
+ os.proc("git", "commit", "-am", s"Setting next version to ${nextVersion}").call()
+ os.proc("git", "push", "origin", "master", "--tags").call()
}
}
diff --git a/integration/test/resources/play-json/headers.sc b/integration/test/resources/play-json/headers.sc
index a66eaedd..9737cb3d 100644
--- a/integration/test/resources/play-json/headers.sc
+++ b/integration/test/resources/play-json/headers.sc
@@ -1,6 +1,6 @@
import $ivy.`com.github.rockjam::license-headers:0.0.1`
-import ammonite.ops._
+
import mill._, scalalib._
import mill.eval.PathRef
import de.heikoseeberger.sbtheader.{CommentStyle, FileType, HeaderCreator, License}
@@ -24,7 +24,7 @@ trait Headers extends ScalaModule {
val updatedFiles = withoutHeaders.map {
case (file, updated) =>
- write.over(file, updated)
+ os.write.over(file, updated)
file
}
@@ -47,15 +47,15 @@ trait Headers extends ScalaModule {
private def filesWithoutHeaders(input: Seq[PathRef]) = {
for {
- ref <- input if exists(ref.path)
- file <- ls.rec(ref.path) if file.isFile
+ ref <- input if os.exists(ref.path)
+ file <- os.walk(ref.path) if os.isFile(file)
(fileType, commentStyle) <- headerMappings.get(file.ext)
updatedContent <- HeaderCreator(
fileType,
commentStyle,
license,
log = _ => (),
- read.getInputStream(file)
+ os.read.inputStream(file)
).createText
} yield file -> updatedContent
}
diff --git a/integration/test/resources/play-json/jmh.sc b/integration/test/resources/play-json/jmh.sc
index 76ed43fc..3c2c8411 100644
--- a/integration/test/resources/play-json/jmh.sc
+++ b/integration/test/resources/play-json/jmh.sc
@@ -1,4 +1,4 @@
-import ammonite.ops._
+
import mill._, scalalib._, modules._
trait Jmh extends ScalaModule {
@@ -19,13 +19,13 @@ trait Jmh extends ScalaModule {
def compileGeneratedSources = T {
val dest = T.ctx.dest
val (sourcesDir, _) = generateBenchmarkSources()
- val sources = ls.rec(sourcesDir).filter(_.isFile)
- %%("javac",
+ val sources = os.walk(sourcesDir).filter(os.isFile)
+ os.proc("javac",
sources.map(_.toString),
"-cp",
(runClasspath() ++ generatorDeps()).map(_.path.toString).mkString(":"),
"-d",
- dest)(wd = dest)
+ dest).call(dest)
PathRef(dest)
}
@@ -36,10 +36,10 @@ trait Jmh extends ScalaModule {
val sourcesDir = dest / 'jmh_sources
val resourcesDir = dest / 'jmh_resources
- rm(sourcesDir)
- mkdir(sourcesDir)
- rm(resourcesDir)
- mkdir(resourcesDir)
+ os.remove.all(sourcesDir)
+ os.makeDir.all(sourcesDir)
+ os.remove.all(resourcesDir)
+ os.makeDir.all(resourcesDir)
Jvm.subprocess(
"org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator",
diff --git a/integration/test/resources/play-json/mima.sc b/integration/test/resources/play-json/mima.sc
index 3902f2c7..baca333c 100644
--- a/integration/test/resources/play-json/mima.sc
+++ b/integration/test/resources/play-json/mima.sc
@@ -1,4 +1,4 @@
-import ammonite.ops._
+
import $ivy.`com.typesafe::mima-reporter:0.1.18`
import com.typesafe.tools.mima.lib.MiMaLib
import com.typesafe.tools.mima.core._
@@ -34,7 +34,7 @@ trait MiMa extends ScalaModule with PublishModule {
com.typesafe.tools.mima.core.Config.setup("sbt-mima-plugin", Array.empty)
val cpstring = classpath
.map(_.path)
- .filter(exists)
+ .filter(os.exists)
.mkString(System.getProperty("path.separator"))
new MiMaLib(
com.typesafe.tools.mima.core.reporterClassPath(cpstring)
diff --git a/integration/test/resources/play-json/reformat.sc b/integration/test/resources/play-json/reformat.sc
index c44b2f97..3127bc5d 100644
--- a/integration/test/resources/play-json/reformat.sc
+++ b/integration/test/resources/play-json/reformat.sc
@@ -1,7 +1,7 @@
import $ivy.`org.scalariform::scalariform:0.2.5`
import mill._, scalalib._
-import ammonite.ops._
+
import scalariform.formatter._
import scalariform.formatter.preferences._
import scalariform.parser.ScalaParserException
@@ -25,11 +25,11 @@ trait Scalariform extends ScalaModule {
files.map { path =>
try {
val formatted = ScalaFormatter.format(
- read(path),
+ os.read(path),
playJsonPreferences,
scalaVersion = scalaVersion()
)
- write.over(path, formatted)
+ os.write.over(path, formatted)
} catch {
case ex: ScalaParserException =>
T.ctx.log.error(s"Failed to format file: ${path}. Error: ${ex.getMessage}")
@@ -41,7 +41,7 @@ trait Scalariform extends ScalaModule {
def checkCodeFormat() = T.command {
filesToFormat(sources()).foreach { path =>
try {
- val input = read(path)
+ val input = os.read(path)
val formatted = ScalaFormatter.format(
input,
playJsonPreferences,
@@ -63,8 +63,8 @@ trait Scalariform extends ScalaModule {
private def filesToFormat(sources: Seq[PathRef]) = {
for {
- pathRef <- sources if exists(pathRef.path)
- file <- ls.rec(pathRef.path) if file.isFile && file.ext == "scala"
+ pathRef <- sources if os.exists(pathRef.path)
+ file <- os.walk(pathRef.path) if os.isFile(file) && file.ext == "scala"
} yield file
}
diff --git a/integration/test/resources/play-json/release.sh b/integration/test/resources/play-json/release.sh
index 009300a0..6efe80ce 100755
--- a/integration/test/resources/play-json/release.sh
+++ b/integration/test/resources/play-json/release.sh
@@ -2,7 +2,7 @@
set -eux
-rm -rf out
+os.remove.all -rf out
mill __.test
mill release.setReleaseVersion
mill mill.scalalib.PublishModule/publishAll \
diff --git a/integration/test/resources/upickle/build.sc b/integration/test/resources/upickle/build.sc
index 1f5f2bed..86552d9d 100644
--- a/integration/test/resources/upickle/build.sc
+++ b/integration/test/resources/upickle/build.sc
@@ -43,7 +43,7 @@ trait UpickleModule extends CrossSbtModule with PublishModule{
def generatedSources = T{
val dir = T.ctx().dest
val file = dir / "upickle" / "Generated.scala"
- ammonite.ops.mkdir(dir / "upickle")
+ os.makeDir.all(dir / "upickle")
val tuplesAndCases = (1 to 22).map{ i =>
def commaSeparated(s: Int => String) = (1 to i).map(s).mkString(", ")
val writerTypes = commaSeparated(j => s"T$j: Writer")
diff --git a/integration/test/src/mill/integration/AcyclicTests.scala b/integration/test/src/mill/integration/AcyclicTests.scala
index c117f862..145c106d 100644
--- a/integration/test/src/mill/integration/AcyclicTests.scala
+++ b/integration/test/src/mill/integration/AcyclicTests.scala
@@ -1,6 +1,5 @@
package mill.integration
-import ammonite.ops._
import utest._
class AcyclicTests(fork: Boolean)
@@ -13,11 +12,11 @@ class AcyclicTests(fork: Boolean)
assert(
firstCompile,
- ls.rec(workspacePath).exists(_.last == "GraphAnalysis.class"),
- ls.rec(workspacePath).exists(_.last == "PluginPhase.class")
+ os.walk(workspacePath).exists(_.last == "GraphAnalysis.class"),
+ os.walk(workspacePath).exists(_.last == "PluginPhase.class")
)
- for(scalaFile <- ls.rec(workspacePath).filter(_.ext == "scala")){
- write.append(scalaFile, "\n}")
+ for(scalaFile <- os.walk(workspacePath).filter(_.ext == "scala")){
+ os.write.append(scalaFile, "\n}")
}
val brokenCompile = eval(s"acyclic[$scalaVersion].compile")
diff --git a/integration/test/src/mill/integration/AmmoniteTests.scala b/integration/test/src/mill/integration/AmmoniteTests.scala
index 3f04e84d..2f2c648d 100644
--- a/integration/test/src/mill/integration/AmmoniteTests.scala
+++ b/integration/test/src/mill/integration/AmmoniteTests.scala
@@ -1,6 +1,5 @@
package mill.integration
-import ammonite.ops._
import utest._
class AmmoniteTests(fork: Boolean)
@@ -25,8 +24,8 @@ class AmmoniteTests(fork: Boolean)
assert(
compileResult,
- ls.rec(workspacePath / 'out / 'integration / scalaVersion / 'test / 'compile)
- .exists(_.name == "ErrorTruncationTests.class")
+ os.walk(workspacePath / 'out / 'integration / scalaVersion / 'test / 'compile)
+ .exists(_.last == "ErrorTruncationTests.class")
)
}
diff --git a/integration/test/src/mill/integration/BetterFilesTests.scala b/integration/test/src/mill/integration/BetterFilesTests.scala
index 4f3116f7..bdbaa2e3 100644
--- a/integration/test/src/mill/integration/BetterFilesTests.scala
+++ b/integration/test/src/mill/integration/BetterFilesTests.scala
@@ -1,6 +1,5 @@
package mill.integration
-import ammonite.ops._
import utest._
class BetterFilesTests(fork: Boolean)
@@ -17,8 +16,8 @@ class BetterFilesTests(fork: Boolean)
assert(coreTestMeta.contains("better.files.FileSpec"))
assert(coreTestMeta.contains("files should handle BOM"))
- for(scalaFile <- ls.rec(workspacePath).filter(_.ext == "scala")){
- write.append(scalaFile, "\n}")
+ for(scalaFile <- os.walk(workspacePath).filter(_.ext == "scala")){
+ os.write.append(scalaFile, "\n}")
}
assert(!eval("akka.test"))
}
diff --git a/integration/test/src/mill/integration/DocAnnotationsTests.scala b/integration/test/src/mill/integration/DocAnnotationsTests.scala
index 75579689..4d7ef11b 100644
--- a/integration/test/src/mill/integration/DocAnnotationsTests.scala
+++ b/integration/test/src/mill/integration/DocAnnotationsTests.scala
@@ -1,12 +1,11 @@
package mill.integration
-import ammonite.ops.{Path, pwd}
import mill.util.ScriptTestSuite
import utest._
class DocAnnotationsTests(fork: Boolean) extends ScriptTestSuite(fork) {
def workspaceSlug: String = "docannotations"
- def scriptSourcePath: Path = pwd / 'integration / 'test / 'resources / workspaceSlug
+ def scriptSourcePath: os.Path = os.pwd / 'integration / 'test / 'resources / workspaceSlug
val tests = Tests{
initWorkspace()
'test - {
diff --git a/integration/test/src/mill/integration/IntegrationTestSuite.scala b/integration/test/src/mill/integration/IntegrationTestSuite.scala
index 721557c0..ca041eea 100644
--- a/integration/test/src/mill/integration/IntegrationTestSuite.scala
+++ b/integration/test/src/mill/integration/IntegrationTestSuite.scala
@@ -1,29 +1,28 @@
package mill.integration
-import ammonite.ops._
import mill.util.ScriptTestSuite
import utest._
abstract class IntegrationTestSuite(repoKey: String, val workspaceSlug: String, fork: Boolean)
extends ScriptTestSuite(fork){
- val buildFilePath = pwd / 'integration / 'test / 'resources / workspaceSlug
+ val buildFilePath = os.pwd / 'integration / 'test / 'resources / workspaceSlug
def scriptSourcePath = {
// 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.
val path = sys.props(repoKey)
- val Seq(wrapper) = ls(Path(path))
+ val Seq(wrapper) = os.list(os.Path(path))
wrapper
}
- def buildFiles: Seq[Path] = ls.rec(buildFilePath)
+ def buildFiles: Seq[os.Path] = os.walk(buildFilePath)
override def initWorkspace() = {
super.initWorkspace()
buildFiles.foreach { file =>
- cp.over(file, workspacePath / file.name)
+ os.copy.over(file, workspacePath / file.last)
}
- assert(!ls.rec(workspacePath).exists(_.ext == "class"))
+ assert(!os.walk(workspacePath).exists(_.ext == "class"))
}
}
diff --git a/integration/test/src/mill/integration/JawnTests.scala b/integration/test/src/mill/integration/JawnTests.scala
index da584e01..eafd1009 100644
--- a/integration/test/src/mill/integration/JawnTests.scala
+++ b/integration/test/src/mill/integration/JawnTests.scala
@@ -1,6 +1,5 @@
package mill.integration
-import ammonite.ops._
import utest._
class JawnTests(fork: Boolean)
@@ -13,12 +12,12 @@ class JawnTests(fork: Boolean)
assert(
firstCompile,
- ls.rec(workspacePath).exists(_.last == "AsyncParser.class"),
- ls.rec(workspacePath).exists(_.last == "CharBuilderSpec.class")
+ os.walk(workspacePath).exists(_.last == "AsyncParser.class"),
+ os.walk(workspacePath).exists(_.last == "CharBuilderSpec.class")
)
- for(scalaFile <- ls.rec(workspacePath).filter(_.ext == "scala")){
- write.append(scalaFile, "\n}")
+ for(scalaFile <- os.walk(workspacePath).filter(_.ext == "scala")){
+ os.write.append(scalaFile, "\n}")
}
val brokenCompile = eval(s"jawn[$scalaVersion].parser.test")
diff --git a/integration/test/src/mill/integration/PlayJsonTests.scala b/integration/test/src/mill/integration/PlayJsonTests.scala
index c78a256e..262dcb36 100644
--- a/integration/test/src/mill/integration/PlayJsonTests.scala
+++ b/integration/test/src/mill/integration/PlayJsonTests.scala
@@ -1,12 +1,12 @@
package mill.integration
-import ammonite.ops._
+
import utest._
class PlayJsonTests(fork: Boolean) extends IntegrationTestSuite("MILL_PLAY_JSON_REPO", "play-json", fork) {
- override def buildFiles: Seq[Path] = {
- ls(buildFilePath).filter(_.ext == "sc")
+ override def buildFiles: Seq[os.Path] = {
+ os.list(buildFilePath).filter(_.ext == "sc")
}
val tests = Tests{
diff --git a/integration/test/src/mill/integration/UpickleTests.scala b/integration/test/src/mill/integration/UpickleTests.scala
index 1b83c60f..133188d3 100644
--- a/integration/test/src/mill/integration/UpickleTests.scala
+++ b/integration/test/src/mill/integration/UpickleTests.scala
@@ -1,6 +1,5 @@
package mill.integration
-import ammonite.ops._
import utest._
class UpickleTests(fork: Boolean) extends IntegrationTestSuite("MILL_UPICKLE_REPO", "upickle", fork) {