Skip to content

Commit

Permalink
Try and simplify ExampleTester (#3419)
Browse files Browse the repository at this point in the history
Removes some special case and generalizes them into vanilla subprocess
commands. Bash already exists, so rather than trying to write a
poorly-defined custom DSL that is meant to look like bash and behave
like bash, we just use bash.

Need to figure out how to install `bash` on windows, but once that's
done this lets us cut out a huge amount of cruft and complexity
  • Loading branch information
lihaoyi authored Aug 25, 2024
1 parent b340685 commit a34932e
Show file tree
Hide file tree
Showing 25 changed files with 130 additions and 196 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ jobs:
- java-version: 17
millargs: '"scalajslib.__.test"'
- java-version: 11
millargs: '"example.scalalib.basic.__.local.test"'
millargs: '"example.scalalib.basic.__.fork.test"'
- java-version: 17
millargs: "'integration.feature[_].fork.test'"
- java-version: 11
Expand Down
4 changes: 2 additions & 2 deletions example/depth/cross/6-axes-extension/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ trait FooModule3 extends FooModule2 with Cross.Module3[String, Int, Boolean] {
> mill show foo3[b,2,false].param3
"Param Value: false"
> sed -i 's/, true//g' build.sc
> sed -i.bak 's/, true//g' build.sc
> sed -i 's/, false//g' build.sc
> sed -i.bak 's/, false//g' build.sc
> mill show foo3[b,2,false].param3
error: ...object foo3 extends Cross[FooModule3](("a", 1), ("b", 2))
Expand Down
2 changes: 1 addition & 1 deletion example/depth/cross/9-dynamic-cross-modules/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ error: Cannot resolve modules[new]...
> cp -r modules/bar modules/new
> sed -i 's/Bar/New/g' modules/new/src/Example.scala
> sed -i.bak 's/Bar/New/g' modules/new/src/Example.scala
> mill resolve modules[_]
modules[bar]
Expand Down
2 changes: 1 addition & 1 deletion example/depth/tasks/5-persistent-targets/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Compressing: world.txt
> ./mill compressedData # when no input changes, compressedData does not evaluate at all
> sed -i 's/Hello/HELLO/g' data/hello.txt
> sed -i.bak 's/Hello/HELLO/g' data/hello.txt
> ./mill compressedData # when one input file changes, only that file is re-compressed
Compressing: hello.txt
Expand Down
2 changes: 1 addition & 1 deletion example/depth/tasks/6-workers/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Compressing: world.txt
> ./mill compressedData # when no input changes, compressedData does not evaluate at all
> sed -i 's/Hello/HELLO/g' data/hello.txt
> sed -i.bak 's/Hello/HELLO/g' data/hello.txt
> ./mill compressedData # not --no-server, we read the data from memory
Compressing: hello.txt
Expand Down
2 changes: 1 addition & 1 deletion example/extending/plugins/7-writing-mill-plugins/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ compiling 1 Scala source...

/** Usage
> sed -i 's/0.0.1/0.0.2/g' build.sc
> sed -i.bak 's/0.0.1/0.0.2/g' build.sc
> ./mill myplugin.publishLocal
Publishing Artifact(com.lihaoyi,myplugin_2.13,0.0.2) to ivy repo...
Expand Down
2 changes: 1 addition & 1 deletion example/javalib/web/1-hello-jetty/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object hello extends RootModule with JavaModule {
> mill test
...HelloJettyTest.testHelloJetty finished...
> mill runBackground
> mill runBackground; sleep 2 # give time for server to start
> curl http://localhost:8085
...<h1>Hello, World!</h1>...
Expand Down
2 changes: 1 addition & 1 deletion example/javalib/web/2-hello-spring-boot/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object hello extends RootModule with JavaModule {
> mill test
...com.example.HelloSpringBootTest#shouldReturnDefaultMessage() finished...
> mill runBackground
> mill runBackground; sleep 2 # give time for server to start
> curl http://localhost:8086
...<h1>Hello, World!</h1>...
Expand Down
2 changes: 1 addition & 1 deletion example/javalib/web/3-todo-spring-boot/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ object hello extends RootModule with JavaModule {
...com.example.TodomvcIntegrationTests#homePageLoads() finished...
...com.example.TodomvcIntegrationTests#addNewTodoItem() finished...
> mill test.runBackground
> mill test.runBackground; sleep 2 # give time for server to start
> curl http://localhost:8087
...<h1>todos</h1>...
Expand Down
2 changes: 1 addition & 1 deletion example/javalib/web/4-hello-micronaut/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ trait MicronautModule extends MavenModule{
> mill test
...example.micronaut.HelloControllerTest#testHello()...
> mill runBackground
> mill runBackground; sleep 2 # give time for server to start
> curl http://localhost:8088/hello
...Hello World...
Expand Down
2 changes: 1 addition & 1 deletion example/javalib/web/5-todo-micronaut/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ trait MicronautModule extends MavenModule{
...example.micronaut.TodoItemControllerTest...
...example.micronaut.HtmxWebJarsTest...
> mill runBackground
> mill runBackground; sleep 2 # give time for server to start
> curl http://localhost:8088
...<h1>todos</h1>...
Expand Down
4 changes: 2 additions & 2 deletions example/scalalib/basic/4-builtin-commands/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Inputs:

/** Usage
> mill show "foo.{sources,compileClasspath}"
> mill show 'foo.{sources,compileClasspath}'
{
"foo.sources": [
".../foo/src"
Expand All @@ -179,7 +179,7 @@ Inputs:

/** Usage
> mill showNamed "foo.{sources,compileClasspath}"
> mill showNamed 'foo.{sources,compileClasspath}'
{
"foo.sources": [
".../foo/src"
Expand Down
2 changes: 1 addition & 1 deletion example/scalalib/builds/1-common-config/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ my.custom.property: my-prop-value

/** Usage
> sed -i 's/Foo2 {/Foo2 { println(this + "hello")/g' custom-src/Foo2.scala
> sed -i.bak 's/Foo2 {/Foo2 { println(this + "hello")/g' custom-src/Foo2.scala
> mill compile # demonstrate -deprecation/-Xfatal-warnings flags
error: object Foo2 { println(this + "hello")
Expand Down
4 changes: 2 additions & 2 deletions example/scalalib/module/11-assembly-config/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ object bar extends ScalaModule {
> ./mill foo.assembly
> unzip -p ./out/foo/assembly.dest/out.jar application.conf
> unzip -p ./out/foo/assembly.dest/out.jar application.conf || true
Bar Application Conf
Foo Application Conf
> java -jar ./out/foo/assembly.dest/out.jar\
> java -jar ./out/foo/assembly.dest/out.jar
Loaded application.conf from resources:...
...Foo Application Conf
...Bar Application Conf
Expand Down
2 changes: 1 addition & 1 deletion example/scalalib/module/3-run-compile-deps/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object bar extends ScalaModule {

/** Usage
> ./mill foo.runBackground
> ./mill foo.runBackground; sleep 2 # give time for server to start
> curl http://localhost:8079
<html><body>Hello World!</body></html>
Expand Down
13 changes: 1 addition & 12 deletions example/scalalib/testing/3-integration-suite/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,7 @@ object qux extends ScalaModule {

/** Usage
> mill qux.test # run the normal test suite
...qux.QuxTests...hello...
...qux.QuxTests...world...
> mill qux.integration # run the integration test suite
...qux.QuxIntegrationTests...helloworld...
> mill qux.integration.testCached # run the normal test suite, caching the results
...qux.QuxIntegrationTests...helloworld...
> mill qux.{test,integration} # run both test suites
> mill 'qux.{test,integration}' # run both test suites
...qux.QuxTests...hello...
...qux.QuxTests...world...
...qux.QuxIntegrationTests...helloworld...
Expand Down
2 changes: 1 addition & 1 deletion example/scalalib/web/1-todo-webapp/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object root extends RootModule with ScalaModule {
> ./mill test
+ webapp.WebAppTests.simpleRequest...
> ./mill runBackground
> ./mill runBackground; sleep 2 # give time for server to start
> curl http://localhost:8080
...What needs to be done...
Expand Down
2 changes: 1 addition & 1 deletion example/scalalib/web/2-webapp-cache-busting/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def hashFile(path: os.Path, src: os.Path, dest: os.Path) = {
> ./mill test
+ webapp.WebAppTests.simpleRequest ...
> ./mill runBackground
> ./mill runBackground; sleep 2 # give time for server to start
> curl http://localhost:8081
...What needs to be done...
Expand Down
2 changes: 1 addition & 1 deletion example/scalalib/web/4-webapp-scalajs/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object root extends RootModule with ScalaModule {
> ./mill test
+ webapp.WebAppTests.simpleRequest ...
> ./mill runBackground
> ./mill runBackground; sleep 2 # give time for server to start
> curl http://localhost:8082
...What needs to be done...
Expand Down
2 changes: 1 addition & 1 deletion example/scalalib/web/5-webapp-scalajs-shared/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ object root extends RootModule with AppScalaModule {
> ./mill test
+ webapp.WebAppTests.simpleRequest ...
> ./mill runBackground
> ./mill runBackground; sleep 2 # give time for server to start
> curl http://localhost:8083
...What needs to be done...
Expand Down
2 changes: 1 addition & 1 deletion testkit/src/mill/testkit/ExampleTestSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ object ExampleTestSuite extends IntegrationTestSuite {
val tests: Tests = Tests {

test("exampleTest") {
new ExampleTester(this).run()
new ExampleTester(clientServerMode, workspaceSourcePath, millExecutable).run()
}
}
}
Loading

0 comments on commit a34932e

Please sign in to comment.