-
-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restructure TestModule
, add RunModule
#3064
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
148905a
Introduce a `TestModule.testClasspath` to decouple from compilation
lefou c6809f7
Restructured TestModule, added RunBaseModule, added test case
lefou 8df934b
Print each ran testcase in ExampleTestSuite
lefou f9babf3
docs
lefou ae80a34
Removed TestModule.testRunModule again
lefou 51aed91
Introduce a ZincWorkerAware trait
lefou 2a96c65
Consolidate RunModule
lefou 3ca3e2c
.
lefou e547a6f
.
lefou 2f08d5c
.
lefou 3e3cf7e
Formate expected output
lefou 8296be4
Add MiMa ignore filter and ensure super-calls when we moved defs up
lefou 5aced5c
.
lefou d725414
.
lefou bfc49f0
docs
lefou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import mill._ | ||
import mill.scalalib._ | ||
import mill.scalalib.api.CompilationResult | ||
|
||
object foo extends RootModule with ScalaModule { | ||
def scalaVersion = "2.13.11" | ||
def ivyDeps = Agg( | ||
ivy"com.lihaoyi::scalatags:0.12.0", | ||
ivy"com.lihaoyi::mainargs:0.6.2" | ||
) | ||
|
||
object test extends ScalaTests { | ||
def ivyDeps = Agg( | ||
ivy"com.lihaoyi::utest:0.7.11", | ||
ivy"org.scalatest::scalatest-freespec:3.2.18" | ||
) | ||
def testFramework = "utest.runner.Framework" | ||
} | ||
object test2 extends TestModule with TestModule.ScalaTest { | ||
override def compile: T[CompilationResult] = ??? | ||
override def runClasspath: T[Seq[PathRef]] = foo.test.runClasspath() | ||
override def testClasspath = foo.test.testClasspath() | ||
} | ||
} | ||
|
||
// format: off | ||
/** Usage | ||
|
||
> mill resolve __:TestModule.test | ||
... | ||
test.test | ||
test2.test | ||
|
||
> mill test | ||
... | ||
+ foo.FooTests.simple ... <h1>hello</h1> | ||
+ foo.FooTests.escaping ... <h1><hello></h1> | ||
Tests: 2, Passed: 2, Failed: 0 | ||
> mill test2 | ||
... | ||
FooScalaTests: | ||
Foo | ||
- simple | ||
- escaping | ||
... | ||
Total number of tests run: 2 | ||
Suites: completed 1, aborted 0 | ||
Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0 | ||
|
||
*/ | ||
// format: on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package foo | ||
import scalatags.Text.all._ | ||
import mainargs.{main, ParserForMethods} | ||
|
||
object Foo { | ||
def generateHtml(text: String) = { | ||
h1(text).toString | ||
} | ||
|
||
@main | ||
def main(text: String) = { | ||
println(generateHtml(text)) | ||
} | ||
|
||
def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args) | ||
} |
18 changes: 18 additions & 0 deletions
18
example/basic/5-multiple-test-frameworks/test/src/FooScalaTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package foo | ||
|
||
import org.scalatest.freespec._ | ||
|
||
class FooScalaTests extends AnyFreeSpec { | ||
"Foo" - { | ||
"simple" in { | ||
val result = Foo.generateHtml("hello") | ||
assert(result == "<h1>hello</h1>") | ||
result | ||
} | ||
"escaping" in { | ||
val result = Foo.generateHtml("<hello>") | ||
assert(result == "<h1><hello></h1>") | ||
result | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
example/basic/5-multiple-test-frameworks/test/src/FooTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package foo | ||
import utest._ | ||
object FooTests extends TestSuite { | ||
def tests = Tests { | ||
test("simple") { | ||
val result = Foo.generateHtml("hello") | ||
assert(result == "<h1>hello</h1>") | ||
result | ||
} | ||
test("escaping") { | ||
val result = Foo.generateHtml("<hello>") | ||
assert(result == "<h1><hello></h1>") | ||
result | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package mill.scalalib | ||
|
||
import mill.T | ||
import mill.define.Module | ||
import mill.api.JsonFormatters.pathReadWrite | ||
import mill.api.PathRef | ||
|
||
trait RunModule extends Module { | ||
|
||
/** | ||
* Any command-line parameters you want to pass to the forked JVM. | ||
*/ | ||
def forkArgs: T[Seq[String]] = T { Seq.empty[String] } | ||
|
||
/** | ||
* Any environment variables you want to pass to the forked JVM. | ||
*/ | ||
def forkEnv: T[Map[String, String]] = T.input { T.env } | ||
|
||
def forkWorkingDir: T[os.Path] = T { T.workspace } | ||
|
||
/** | ||
* All classfiles and resources including upstream modules and dependencies | ||
* necessary to run this module's code. | ||
*/ | ||
def runClasspath: T[Seq[PathRef]] = T { Seq.empty[PathRef] } | ||
|
||
/** | ||
* Control whether `run*`-targets should use an args file to pass command line args, if possible. | ||
*/ | ||
def runUseArgsFile: T[Boolean] = T { scala.util.Properties.isWin } | ||
|
||
// def zincWorker: ModuleRef[ZincWorkerModule] = ModuleRef(mill.scalalib.ZincWorkerModule) | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling
super
here but without callingapply
, so even when not actual using the super-target here (we don't insert a real dependency to the super-target), we ensure thesuper
-reference is generated in the byte-code. This allows us later to use the super-target without worrying about binary compatibility.This is some new pattern I want to try out and establish. If it works out, we could automate it in the
T
-macros.See for more details: