Skip to content

Commit

Permalink
Add smoketest for incremental compilation of multi-file build (#3750)
Browse files Browse the repository at this point in the history
Seems there's a bug in sbt/zinc#1461 causing
over-compilation, for now just assert the misbehavior
  • Loading branch information
lihaoyi authored Oct 16, 2024
1 parent 46271c1 commit b9fbaad
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ object CodeSigSubfolderTests extends UtestIntegrationTestSuite {
// Changing stuff in subfolder/package.mill does not invalidate unrelated tasks in build.mill
val cached3 = eval("foo")
assert(cached3.out == "")
// TODO: why is this compiling both sources when we only changed
// one file and did not change any public type signatures?
// This should only compile 1 source but it seems there's an upstream bug in Zinc
// https://github.com/sbt/zinc/issues/1461
assert(cached3.err.contains("compiling 2 Scala sources"))

modifyFile(
Expand All @@ -56,8 +56,8 @@ object CodeSigSubfolderTests extends UtestIntegrationTestSuite {
)
val mangledHelperFoo = eval("foo")
assert(mangledHelperFoo.out.linesIterator.toSeq == Seq("running foo2", "running helperFoo2"))
// TODO: why is this compiling both sources when we only changed
// one file and did not change any public type signatures?
// This should only compile 1 source but it seems there's an upstream bug in Zinc
// https://github.com/sbt/zinc/issues/1461
assert(mangledHelperFoo.err.contains("compiling 2 Scala sources"))

// Make sure changing `val`s, which only affects the Module constructor and
Expand All @@ -68,8 +68,8 @@ object CodeSigSubfolderTests extends UtestIntegrationTestSuite {
)
val mangledValFoo = eval("foo")
assert(mangledValFoo.out.linesIterator.toSeq == Seq("running foo2", "running helperFoo2"))
// TODO: why is this compiling both sources when we only changed
// one file and did not change any public type signatures?
// This should only compile 1 source but it seems there's an upstream bug in Zinc
// https://github.com/sbt/zinc/issues/1461
assert(mangledValFoo.err.contains("compiling 2 Scala sources"))

// Even modifying `val`s that do not affect the task invalidates it, because
Expand All @@ -85,8 +85,8 @@ object CodeSigSubfolderTests extends UtestIntegrationTestSuite {
"running helperFoo2"
))

// TODO: why is this compiling both sources when we only changed
// one file and did not change any public type signatures?
// This should only compile 1 source but it seems there's an upstream bug in Zinc
// https://github.com/sbt/zinc/issues/1461
assert(mangledValFooUsedInBar.err.contains("compiling 2 Scala sources"))

val cached4 = eval("foo")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package build
import $packages._
import mill._


def foo = { println("running foo"); build_.subfolder.package_.helperFoo }

def dummy = Task{ 1 }
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package build.subfolder
import mill._

val valueFoo = 0
val valueFooUsedInBar = 0
def helperFoo = { println("running helperFoo"); 1 + valueFoo }
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package mill.integration

import mill.testkit.UtestIntegrationTestSuite

import utest._

object ZincBuildCompilationTests extends UtestIntegrationTestSuite {
val tests: Tests = Tests {
test("simple") - integrationTest { tester =>
import tester._

val initial = eval(("dummy"))

assert(initial.err.contains("compiling 2 Scala sources"))

val cached = eval(("dummy"))
assert(!cached.err.contains("compiling"))

modifyFile(workspacePath / "build.mill", _.replace("running foo", "running foo2"))
val mangledFoo = eval(("dummy"))
assert(mangledFoo.err.contains("compiling 1 Scala source"))

val cached2 = eval(("dummy"))
assert(!cached2.err.contains("compiling"))

val subFolderResCached = eval(("dummy"))
assert(!subFolderResCached.err.contains("compiling"))

modifyFile(
workspacePath / "subfolder/package.mill",
_.replace("running helperFoo", "running helperFoo2")
)
val mangledHelperFoo = eval(("dummy"))
// This should only compile 1 source but it seems there's an upstream bug in Zinc
// https://github.com/sbt/zinc/issues/1461
assert(mangledHelperFoo.err.contains("compiling 2 Scala source"))

}
}
}
1 change: 0 additions & 1 deletion main/src/mill/main/MainModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ object MainModule {
trait MainModule extends BaseModule0 {

object interp extends Interp
// implicit def millDiscover: mill.define.Discover[_]

/**
* Show the mill version.
Expand Down

0 comments on commit b9fbaad

Please sign in to comment.