From 4baa7ed42377f420b72c639053996d6f14033d12 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 24 Oct 2024 08:58:11 +0800 Subject: [PATCH] Update .mill-version (#300) --- .mill-version | 2 +- build.sc | 4 +++- mill | 6 ++++-- os/test/src-jvm/ExampleTests.scala | 2 +- os/test/src-jvm/OpTestsJvmOnly.scala | 4 ++-- os/test/src-jvm/ProcessPipelineTests.scala | 2 +- os/test/src/OpTests.scala | 2 +- os/test/src/SubprocessTests.scala | 8 ++++++-- os/test/src/TestUtil.scala | 2 +- 9 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.mill-version b/.mill-version index bd0119f9..ac454c6a 100644 --- a/.mill-version +++ b/.mill-version @@ -1 +1 @@ -0.11.12 +0.12.0 diff --git a/build.sc b/build.sc index 734c2416..419b69eb 100644 --- a/build.sc +++ b/build.sc @@ -101,7 +101,8 @@ trait OsLibModule // we check the textual output of system commands and expect it in english def forkEnv = super.forkEnv() ++ Map( "LC_ALL" -> "C", - "TEST_SUBPROCESS_ENV" -> "value" + "TEST_SUBPROCESS_ENV" -> "value", + "OS_TEST_RESOURCE_FOLDER" -> os.jvm(crossValue).test.resources().head.path.toString ) } } @@ -206,6 +207,7 @@ object os extends Module { def ivyDeps = Agg(Deps.jna) object test extends ScalaTests with OsLibTestModule { def moduleDeps = super.moduleDeps ++ Seq(os.jvm().test) + } } } diff --git a/mill b/mill index cb1ee32f..d03a045c 100755 --- a/mill +++ b/mill @@ -7,7 +7,7 @@ set -e if [ -z "${DEFAULT_MILL_VERSION}" ] ; then - DEFAULT_MILL_VERSION=0.11.0 + DEFAULT_MILL_VERSION=0.11.12 fi if [ -z "$MILL_VERSION" ] ; then @@ -53,7 +53,9 @@ if [ -z "$MILL_MAIN_CLI" ] ; then fi MILL_FIRST_ARG="" -if [ "$1" = "--bsp" ] || [ "$1" = "-i" ] || [ "$1" = "--interactive" ] || [ "$1" = "--no-server" ] || [ "$1" = "--repl" ] || [ "$1" = "--help" ] ; then + + # first arg is a long flag for "--interactive" or starts with "-i" +if [ "$1" = "--bsp" ] || [ "${1#"-i"}" != "$1" ] || [ "$1" = "--interactive" ] || [ "$1" = "--no-server" ] || [ "$1" = "--repl" ] || [ "$1" = "--help" ] ; then # Need to preserve the first position of those listed options MILL_FIRST_ARG=$1 shift diff --git a/os/test/src-jvm/ExampleTests.scala b/os/test/src-jvm/ExampleTests.scala index a082369f..b4a1b861 100644 --- a/os/test/src-jvm/ExampleTests.scala +++ b/os/test/src-jvm/ExampleTests.scala @@ -254,7 +254,7 @@ object ExampleTests extends TestSuite { } test("findWc") { - val wd = os.pwd / "os/test/resources/test" + val wd = os.Path(sys.env("OS_TEST_RESOURCE_FOLDER")) / "test" // find . -name '*.txt' | xargs wc -l val lines = os.walk(wd) diff --git a/os/test/src-jvm/OpTestsJvmOnly.scala b/os/test/src-jvm/OpTestsJvmOnly.scala index d32fe830..1d516ec1 100644 --- a/os/test/src-jvm/OpTestsJvmOnly.scala +++ b/os/test/src-jvm/OpTestsJvmOnly.scala @@ -10,7 +10,7 @@ import java.nio.charset.Charset object OpTestsJvmOnly extends TestSuite { val tests = Tests { - val res = os.pwd / "os/test/resources/test" + val res = os.Path(sys.env("OS_TEST_RESOURCE_FOLDER")) / "test" val testFolder = os.pwd / "out/scratch/test" test("lsRecPermissions") { if (Unix()) { @@ -74,7 +74,7 @@ object OpTestsJvmOnly extends TestSuite { // Not sure why this doesn't work on native test("redirectSubprocessInheritedOutput") { if (Unix()) { // relies on bash scripts that don't run on windows - val scriptFolder = os.pwd / "os/test/resources/test" + val scriptFolder = os.Path(sys.env("OS_TEST_RESOURCE_FOLDER")) / "test" val lines = collection.mutable.Buffer.empty[String] os.Inherit.out.withValue(os.ProcessOutput.Readlines(lines.append(_))) { // Redirected diff --git a/os/test/src-jvm/ProcessPipelineTests.scala b/os/test/src-jvm/ProcessPipelineTests.scala index 94de621e..389fcfc8 100644 --- a/os/test/src-jvm/ProcessPipelineTests.scala +++ b/os/test/src-jvm/ProcessPipelineTests.scala @@ -9,7 +9,7 @@ import TestUtil.prep import scala.util.Try object ProcessPipelineTests extends TestSuite { - val scriptFolder = pwd / "os/test/resources/scripts" + val scriptFolder = os.Path(sys.env("OS_TEST_RESOURCE_FOLDER")) / "scripts" lazy val scalaHome = sys.env("SCALA_HOME") diff --git a/os/test/src/OpTests.scala b/os/test/src/OpTests.scala index 433d960f..132ecbe8 100644 --- a/os/test/src/OpTests.scala +++ b/os/test/src/OpTests.scala @@ -10,7 +10,7 @@ import java.nio.charset.Charset object OpTests extends TestSuite { val tests = Tests { - val res = os.pwd / "os/test/resources/test" + val res = os.Path(sys.env("OS_TEST_RESOURCE_FOLDER")) / "test" test("ls") - assert( os.list(res).toSet == Set( res / "folder1", diff --git a/os/test/src/SubprocessTests.scala b/os/test/src/SubprocessTests.scala index 8e532925..5743304d 100644 --- a/os/test/src/SubprocessTests.scala +++ b/os/test/src/SubprocessTests.scala @@ -9,7 +9,7 @@ import utest._ import scala.collection.mutable object SubprocessTests extends TestSuite { - val scriptFolder = pwd / "os/test/resources/test" + val scriptFolder = os.Path(sys.env("OS_TEST_RESOURCE_FOLDER")) / "test" val lsCmd = if (scala.util.Properties.isWin) "dir" else "ls" @@ -38,6 +38,8 @@ object SubprocessTests extends TestSuite { } } test("chained") { + proc("git", "init").call() + os.write.over(os.pwd / "Readme.adoc", "hello") assert( proc("git", "init").call().out.text().contains("Reinitialized existing Git repository"), proc("git", "init").call().out.text().contains("Reinitialized existing Git repository"), @@ -46,6 +48,8 @@ object SubprocessTests extends TestSuite { } test("basicList") { val files = List("Readme.adoc", "build.sc") + os.write.over(os.pwd / "Readme.adoc", "hello") + os.write.over(os.pwd / "build.sc", "world") val output = TestUtil.proc(lsCmd, files).call().out.text() assert(files.forall(output.contains)) } @@ -193,7 +197,7 @@ object SubprocessTests extends TestSuite { } test("jarTf") { // This was the original repro for the multi-chunk concurrency bugs - val jarFile = os.pwd / "os/test/resources/misc/out.jar" + val jarFile = os.Path(sys.env("OS_TEST_RESOURCE_FOLDER")) / "misc/out.jar" assert(TestUtil.eqIgnoreNewlineStyle( os.proc("jar", "-tf", jarFile).call().out.text(), """META-INF/MANIFEST.MF diff --git a/os/test/src/TestUtil.scala b/os/test/src/TestUtil.scala index 49eec2f7..e65a7a79 100644 --- a/os/test/src/TestUtil.scala +++ b/os/test/src/TestUtil.scala @@ -57,7 +57,7 @@ object TestUtil { } ) - val original = Paths.get("os", "test", "resources", "test") + val original = Paths.get(sys.env("OS_TEST_RESOURCE_FOLDER"), "test") Files.walkFileTree( original, new SimpleFileVisitor[Path]() {