I went ahead and used the way of defining tests in Mill rather than doing it more manually. This ensures we get the SBT default src/test/scala and src/test/resource directories for free. It's also just more idiomatic as this is what the Mill examples do.
These tests can be run in parallel with ./mill -j0 __.test. I also figured out how to create "aggregate commands" that run in parallel (if you tell mill to use parallelism with -j):
object utils {
// Copied from https://github.com/com-lihaoyi/mill/blob/4caadfb62581b4c1772c14c6f8dc8963011eaec7/main/define/src/mill/define/Task.scala#L55
// This makes it possible to run multiple tasks in parallel (when passing `-j <n>` to mill)
// Mill's source has MIT license
class Sequence[+T](inputs0: Seq[Task[T]]) extends Task[Seq[T]] {
val inputs: Seq[Task[_]] = inputs0
def evaluate(ctx: mill.api.Ctx): mill.api.Result[Seq[T]] = {
for (i <- 0 until ctx.args.length)
yield ctx.args(i).asInstanceOf[T]
}
}
// end copied from Mill
// Sugar API over Sequence
def parallelize[T](tasks: Seq[Task[T]]): Task[Seq[T]] = new Sequence(tasks)
}
object test extends TaskModule {
override def defaultCommandName() = "run"
val tasks = Seq(
svsim(v.scalaVersion).test.test(),
firrtl(v.scalaVersion).test.test(),
chisel(v.scalaVersion).test.test(),
integrationTests(v.scalaVersion).test.test()
)
def run() = T.command {
utils.parallelize(tasks)()
}
}
I don't think we need this yet, but if we ever want command "aliases", this approach might be useful.
Contributor Checklist
[ ] Did you add Scaladoc to every public function/method?
[ ] Did you add at least one test demonstrating the PR?
[x] Did you delete any extraneous printlns/debugging code?
[x] Did you specify the type of improvement?
[ ] Did you add appropriate documentation in docs/src?
[x] Did you request a desired merge strategy?
[ ] Did you add text to be included in the Release Notes for this change?
Type of Improvement
Internal or build-related (includes code refactoring/cleanup)
Desired Merge Strategy
Squash
Release Notes
Reviewer Checklist (only modified by reviewer)
[ ] Did you add the appropriate labels? (Select the most appropriate one based on the "Type of Improvement")
[ ] Did you mark the proper milestone (Bug fix: 3.6.x, 5.x, or 6.x depending on impact, API modification or big change: 7.0)?
[ ] Did you review?
[ ] Did you check whether all relevant Contributor checkboxes have been checked?
[ ] Did you do one of the following when ready to merge:
[ ] Squash: You/ the contributor Enable auto-merge (squash), clean up the commit message, and label with Please Merge.
[ ] Merge: Ensure that contributor has cleaned up their commit history, then merge with Create a merge commit.
Fixes https://github.com/chipsalliance/chisel/issues/4353.
Another step toward replacing SBT.
I went ahead and used the way of defining tests in Mill rather than doing it more manually. This ensures we get the SBT default
src/test/scala
andsrc/test/resource
directories for free. It's also just more idiomatic as this is what the Mill examples do.These tests can be run in parallel with
./mill -j0 __.test
. I also figured out how to create "aggregate commands" that run in parallel (if you tell mill to use parallelism with-j
):I don't think we need this yet, but if we ever want command "aliases", this approach might be useful.
Contributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
Reviewer Checklist (only modified by reviewer)
3.6.x
,5.x
, or6.x
depending on impact, API modification or big change:7.0
)?Enable auto-merge (squash)
, clean up the commit message, and label withPlease Merge
.Create a merge commit
.