Skip to content

Commit

Permalink
Rename TestModule#test to testForked (#4577)
Browse files Browse the repository at this point in the history
Fixes #4124

The name `testForked` is chosen to fit in with `testLocal`,
`testCached`, etc.
  • Loading branch information
lihaoyi authored Feb 18, 2025
1 parent 4ae3878 commit 233664f
Show file tree
Hide file tree
Showing 46 changed files with 101 additions and 90 deletions.
11 changes: 8 additions & 3 deletions ci/mill-bootstrap.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/build.mill b/build.mill
index 93bd1656426..9d704ff7fbc 100644
index ce02c1bc1a0..df2271c63a5 100644
--- a/build.mill
+++ b/build.mill
@@ -1,16 +1,16 @@
Expand Down Expand Up @@ -493,7 +493,7 @@ index 62190fd6c1e..9d4f176c915 100644
val (repoPath, repoHash) = repoInfo(crossValue)
def repoSlug = repoPath.split("/").last
diff --git a/integration/package.mill b/integration/package.mill
index af00b40d3f0..303bb74cbc0 100644
index af00b40d3f0..e43343cabf1 100644
--- a/integration/package.mill
+++ b/integration/package.mill
@@ -3,13 +3,12 @@ package build.integration
Expand All @@ -520,7 +520,12 @@ index af00b40d3f0..303bb74cbc0 100644

def moduleDeps = Seq(build.main.test, build.testkit, build.runner)

@@ -38,7 +37,7 @@ object `package` extends RootModule {
@@ -34,11 +33,11 @@ object `package` extends RootModule {
def forkEnv: T[Map[String, String]]
def testExclusive = false
trait ModeModule extends build.MillBaseTestsModule {
- override def test(args: String*) = Task.Command(exclusive = testExclusive) {
+ override def testForked(args: String*) = Task.Command(exclusive = testExclusive) {
testTask(Task.Anon { args }, Task.Anon { Seq.empty[String] })()
}

Expand Down
2 changes: 1 addition & 1 deletion ci/test-mill-bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ rm -rf out

# Run tests
./mill-assembly.jar -i "__.compile"
./mill-assembly.jar -i "example.scalalib.basic[1-simple].packaged.server.test"
./mill-assembly.jar -i "example.scalalib.basic[1-simple].packaged.server.testForked"
6 changes: 3 additions & 3 deletions contrib/testng/test/src/mill/testng/TestNGTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ object TestNGTests extends TestSuite {
}
test("Test case lookup from inherited annotations") - UnitTester(demo, resourcePath).scoped {
eval =>
val Right(result) = eval.apply(demo.test.test()): @unchecked
val Right(result) = eval.apply(demo.test.testForked()): @unchecked
val tres = result.value
assert(tres._2.size == 8)
}
test("noGrouping") - UnitTester(demo, resourcePath).scoped {
eval =>
val Right(result) = eval.apply(demo.testng.test()): @unchecked
val Right(result) = eval.apply(demo.testng.testForked()): @unchecked
val tres = result.value._2
assert(tres.map(_.fullyQualifiedName).toSet == Set("foo.HelloTests", "foo.WorldTests"))
}
test("testForkGrouping") - UnitTester(demo, resourcePath).scoped {
eval =>
val Right(result) = eval.apply(demo.testngGrouping.test()): @unchecked
val Right(result) = eval.apply(demo.testngGrouping.testForked()): @unchecked
val tres = result.value._2
assert(tres.map(_.fullyQualifiedName).toSet == Set("foo.HelloTests", "foo.WorldTests"))
}
Expand Down
2 changes: 1 addition & 1 deletion example/android/javalib/1-hello-world/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ object app extends AndroidAppModule {
> ./mill show app.test
...compiling 1 Java source...

> cat out/app/test/test.dest/out.json
> cat out/app/test/testForked.dest/out.json
["",[{"fullyQualifiedName":"com.helloworld.ExampleUnitTest.textSize_isCorrect","selector":"com.helloworld.ExampleUnitTest.textSize_isCorrect","duration":...,"status":"Success"}]]

*/
Expand Down
4 changes: 2 additions & 2 deletions example/android/kotlinlib/1-hello-kotlin/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ object app extends AndroidAppKotlinModule {
> ./mill show app.test
...Compiling 2 Kotlin sources...

> cat out/app/test/test.dest/out.json
> cat out/app/test/testForked.dest/out.json
["",[...{"fullyQualifiedName":"com.helloworld.ExampleUnitTest.text_size_is_correct","selector":"com.helloworld.ExampleUnitTest.text_size_is_correct","duration":...,"status":"Success"}...]]

> cat out/app/test/test.dest/out.json
> cat out/app/test/testForked.dest/out.json
["",[...{"fullyQualifiedName":"com.helloworld.ExampleUnitTestInKotlinDir.kotlin_dir_text_size_is_correct","selector":"com.helloworld.ExampleUnitTestInKotlinDir.kotlin_dir_text_size_is_correct","duration":...,"status":"Success"}...]]

*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ object app extends AndroidAppKotlinModule {

/** Usage

> ./mill show app.screenshotTest.test
> ./mill show app.screenshotTest.testForked
...
[
"",
Expand All @@ -99,7 +99,7 @@ object app extends AndroidAppKotlinModule {
]
...

> cat out/app/screenshotTest/test.dest/test-report.xml
> cat out/app/screenshotTest/testForked.dest/test-report.xml
...
<?xml version='1.0' encoding='UTF-8'?>
<testsuites tests="1" failures="0" errors="0" skipped="0" time="...">
Expand Down
12 changes: 6 additions & 6 deletions example/depth/sandbox/2-test/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ object bar extends MyModule
// With Mill's test sandboxing, each test runs in a separate folder: the `.dest` folder
// of the respective task and module. For example:
//
// - `foo.test` runs in `out/foo/test/test.dest/`
// - `bar.test` runs in `out/bar/test/test.dest/`
// - `foo.test` runs in `out/foo/test/testForked.dest/`
// - `bar.test` runs in `out/bar/test/testForked.dest/`
//
// As a result, each test's `generated.html` file is written to its own dedicated
// working directory, without colliding with each other on disk:

/** Usage

> find . | grep generated.html
.../out/foo/test/test.dest/sandbox/generated.html
.../out/bar/test/test.dest/sandbox/generated.html
.../out/foo/test/testForked.dest/sandbox/generated.html
.../out/bar/test/testForked.dest/sandbox/generated.html

> cat out/foo/test/test.dest/sandbox/generated.html
> cat out/foo/test/testForked.dest/sandbox/generated.html
<h1>hello</h1>

> cat out/bar/test/test.dest/sandbox/generated.html
> cat out/bar/test/testForked.dest/sandbox/generated.html
<p>world</p>

*/
Expand Down
4 changes: 2 additions & 2 deletions example/depth/sandbox/3-breaking/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ object foo extends JavaModule {

> find . | grep .html
...
.../out/foo/test/test.dest/sandbox/foo.html
.../out/foo/test/testForked.dest/sandbox/foo.html

> cat out/foo/test/test.dest/sandbox/foo.html
> cat out/foo/test/testForked.dest/sandbox/foo.html
<h1>foo</h1>

*/
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object bartest extends MyTestModule {

/** Usage

> mill __.test
> mill __.testForked
Test foo.FooTests.simple finished, ...
Test bar.BarTests.simple finished, ...
...
Expand Down
2 changes: 1 addition & 1 deletion example/javalib/basic/4-compat-modules/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ compiling 1 Java source...
> mill foo.test.compile
compiling 1 Java source...

> mill foo.test.test
> mill foo.test.testForked
...foo.FooTests.hello ...

> mill foo.test
Expand Down
2 changes: 1 addition & 1 deletion example/kotlinlib/basic/4-compat-modules/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Compiling 1 Kotlin source...
> mill foo.test.compile
Compiling 1 Kotlin source...

> mill foo.test.test
> mill foo.test.testForked
...foo.FooTests hello ...

> mill foo.test
Expand Down
17 changes: 9 additions & 8 deletions example/large/selective/9-selective-execution/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ Test run qux.QuxTests finished: 1 failed, 0 ignored, 1 total, ...
> echo '//' >> bar/src/bar/Bar.java # emulate the code change

> mill selective.resolve __.test # dry-run selective execution to show what would get run
foo.test.test
bar.test.test
foo.test.testForked
bar.test.testForked

> mill selective.run __.test
Test run foo.FooTests finished: 0 failed, 0 ignored, 1 total, ...
Expand Down Expand Up @@ -159,7 +159,7 @@ bar.sources
"bar.test.compile": {
"bar.test.localRunClasspath": {
"bar.test.testClasspath": {
"bar.test.test": {}
"bar.test.testForked": {}
}
}
}
Expand All @@ -169,11 +169,11 @@ bar.sources
"bar.allSources": {
"bar.allSourceFiles": {
"bar.compile": {
"bar.localRunClasspath": {
"bar.localClasspath": {
"foo.test.transitiveLocalClasspath": {
"foo.test.runClasspath": {
"foo.test.test": {}
"foo.test.upstreamCompileOutput": {
"foo.test.compile": {
"foo.test.localRunClasspath": {
"foo.test.testClasspath": {
"foo.test.testForked": {}
}
}
}
Expand All @@ -184,6 +184,7 @@ bar.sources
}
}


*/

// Similarly, if we make a change `qux/`, using selective execution will only run tests
Expand Down
4 changes: 2 additions & 2 deletions example/pythonlib/testing/1-test-suite/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object foo extends PythonModule {
> ./mill foo.run
Hello World

> ./mill foo.test.test
> ./mill foo.test.testForked
test_hello (test_foo.TestScript...) ... ok
test_mock (test_foo.TestScript...) ... ok
test_world (test_foo.TestScript...) ... ok
Expand Down Expand Up @@ -97,7 +97,7 @@ OK
*/

// * `foo.test`: runs tests in a subprocess in an empty `sandbox/` folder. This is short
// for `foo.test.test`, as `test` is the default task for ``TestModule``s.
// for `foo.test.testForked`, as `testForked` is the default task for ``TestModule``s.

/** Usage

Expand Down
2 changes: 1 addition & 1 deletion example/scalalib/basic/4-compat-modules/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ compiling 1 Scala source...
> mill foo.test.compile
compiling 1 Scala source...

> mill foo.test.test
> mill foo.test.testForked
+ foo.FooTests...hello ...

> mill foo.test
Expand Down
4 changes: 2 additions & 2 deletions example/scalalib/testing/1-test-suite/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ compiling 1 ... source...
> mill foo.test.compile
compiling 1 ... source...

> mill foo.test.test
> mill foo.test.testForked
...foo.FooTests...hello ...
...foo.FooTests...world ...

Expand Down Expand Up @@ -96,7 +96,7 @@ object bar extends ScalaModule {
> mill foo.test
*/
// `foo.test`: runs tests in a subprocess in an empty `sandbox/` folder. This is short
// for `foo.test.test`, as `test` is the default task for ``TestModule``s.
// for `foo.test.testForked`, as `testForked` is the default task for ``TestModule``s.

/** Usage
> mill foo.test.testCached
Expand Down
12 changes: 6 additions & 6 deletions example/scalalib/testing/4-test-grouping/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ object foo extends ScalaModule {

> mill foo.test

> find out/foo/test/test.dest
> find out/foo/test/testForked.dest
...
out/foo/test/test.dest/foo.HelloTests.log
out/foo/test/test.dest/foo.HelloTests/sandbox
out/foo/test/test.dest/foo.WorldTests.log
out/foo/test/test.dest/foo.WorldTests/sandbox
out/foo/test/test.dest/test-report.xml
out/foo/test/testForked.dest/foo.HelloTests.log
out/foo/test/testForked.dest/foo.HelloTests/sandbox
out/foo/test/testForked.dest/foo.WorldTests.log
out/foo/test/testForked.dest/foo.WorldTests/sandbox
out/foo/test/testForked.dest/test-report.xml

*/

Expand Down
8 changes: 4 additions & 4 deletions example/thirdparty/arrow/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ object `package` extends RootModule {
if (modulesWithTestingEnabled(multiplatformRoot)) super.compile
else Task { CompilationResult(Task.dest, PathRef(Task.dest)) }

override def test(args: String*): Command[(String, Seq[TestResult])] =
if (modulesWithTestingEnabled(multiplatformRoot)) super.test(args: _*)
override def testForked(args: String*): Command[(String, Seq[TestResult])] =
if (modulesWithTestingEnabled(multiplatformRoot)) super.testForked(args: _*)
else Task.Command { ("", Seq.empty[TestResult]) }

override def sources: T[Seq[PathRef]] = Task.Sources {
Expand Down Expand Up @@ -203,8 +203,8 @@ object `package` extends RootModule {
if (modulesWithTestingEnabled(jvmRoot)) super.compile
else Task { CompilationResult(Task.dest, PathRef(Task.dest)) }

override def test(args: String*): Command[(String, Seq[TestResult])] =
if (modulesWithTestingEnabled(jvmRoot)) super.test(args: _*)
override def testForked(args: String*): Command[(String, Seq[TestResult])] =
if (modulesWithTestingEnabled(jvmRoot)) super.testForked(args: _*)
else Task.Command { ("", Seq.empty[TestResult]) }
}
}
Expand Down
6 changes: 4 additions & 2 deletions example/thirdparty/netty/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ object `testsuite-http2` extends NettyTestSuiteModule {
os.proc("tar", "xzf", Task.dest / "h2spec.tar.gz").call(cwd = Task.dest)
PathRef(Task.dest / "h2spec")
}
override def test(args: String*) = Task.Command {
override def testForked(args: String*) = Task.Command {
val server = os.proc(assembly().path).spawn(stdout = os.Inherit)
try {
Thread.sleep(1000) // let the server start up
Expand Down Expand Up @@ -641,7 +641,9 @@ object `transport-udt` extends NettyModule {
...Test io.netty.handler.codec.stomp.StompSubframeEncoderTest#testEscapeStompHeaders() finished...
...

> ./mill 'transport-{blockhound-tests,native-unix-common,sctp}.test'
> ./mill 'transport-blockhound-tests.testForked'

> ./mill 'transport-{native-unix-common,sctp}.test'
...Test io.netty.channel.unix.UnixChannelUtilTest#testUnPooledAllocatorIsBufferCopyNeededForWrite() started
...Test io.netty.channel.unix.UnixChannelUtilTest#testUnPooledAllocatorIsBufferCopyNeededForWrite() finished...
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<orderEntry type="sourceFolder" forTests="false"/>
<orderEntry type="library" name="scala-SDK-3.6.2" level="project"/>
<orderEntry type="library" name="SNAPSHOT.jar" level="project"/>
<orderEntry type="library" name="mill-moduledefs_3-0.11.3-M3.jar" level="project"/>
<orderEntry type="library" name="mill-moduledefs_3-0.11.3-M4.jar" level="project"/>
<orderEntry type="library" name="scala-library-2.13.15.jar" level="project"/>
<orderEntry type="library" name="scala3-library_3-3.6.2.jar" level="project"/>
</component>
Expand Down
4 changes: 2 additions & 2 deletions javascriptlib/src/mill/javascriptlib/TestModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import mill.*
trait TestModule extends TaskModule {
import TestModule.TestResult

def test(args: String*): Command[TestResult] =
def testForked(args: String*): Command[TestResult] =
Task.Command {
testTask(Task.Anon { args })()
}
Expand All @@ -18,7 +18,7 @@ trait TestModule extends TaskModule {

protected def testTask(args: Task[Seq[String]]): Task[TestResult]

override def defaultCommandName() = "test"
override def defaultCommandName() = "testForked"
}

object TestModule {
Expand Down
2 changes: 1 addition & 1 deletion kotlinlib/src/mill/kotlinlib/js/KotlinJsModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ trait KotlinJsModule extends KotlinModule { outer =>

override def testLocal(args: String*): Command[(String, Seq[TestResult])] =
Task.Command {
this.test(args*)()
this.testForked(args*)()
}

override protected[js] def friendModule: Option[KotlinJsModule] = Some(outer)
Expand Down
4 changes: 2 additions & 2 deletions kotlinlib/test/src/mill/kotlinlib/HelloKotlinTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ object HelloKotlinTests extends TestSuite {
val eval = testEval()

HelloKotlin.main.crossModules.foreach(m => {
val Left(ExecResult.Failure(_)) = eval.apply(m.test.test()): @unchecked
val Left(ExecResult.Failure(_)) = eval.apply(m.test.testForked()): @unchecked
})
}
test("kotest") {
Expand All @@ -106,7 +106,7 @@ object HelloKotlinTests extends TestSuite {
val Right(discovered) = eval.apply(m.kotest.discoveredTestClasses): @unchecked
assert(discovered.value == Seq("hello.tests.FooTest"))

val Left(ExecResult.Failure(_)) = eval.apply(m.kotest.test()): @unchecked
val Left(ExecResult.Failure(_)) = eval.apply(m.kotest.testForked()): @unchecked
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ object MixedHelloWorldTests extends TestSuite {
val eval = testEval()
MixedHelloWorldKotlin.main.crossModules.foreach(m => {

val Left(ExecResult.Failure(_)) = eval.apply(m.test.test()): @unchecked
val Left(ExecResult.Failure(_)) = eval.apply(m.test.testForked()): @unchecked

// assert(
// v1._2(0).fullyQualifiedName == "hello.tests.HelloTest.testFailure",
Expand Down
Loading

0 comments on commit 233664f

Please sign in to comment.