-
-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
163 additions
and
20 deletions.
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
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
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,65 @@ | ||
package mill.scalalib | ||
|
||
import mill.api.BuildScriptException | ||
import mill.util.{TestEvaluator, TestUtil} | ||
import utest.framework.TestPath | ||
import utest.{TestSuite, Tests, compileError, intercept, test, assert} | ||
|
||
object CycleTests extends TestSuite { | ||
|
||
object CycleBase extends TestUtil.BaseModule { | ||
// See issue: https://github.com/com-lihaoyi/mill/issues/2341 | ||
object a extends ScalaModule { | ||
override def moduleDeps = Seq(a) | ||
override def scalaVersion = sys.props.getOrElse("TEST_SCALA_VERSION", ???) | ||
} | ||
object b extends JavaModule { | ||
override def moduleDeps = Seq(c) | ||
object c extends JavaModule { | ||
override def moduleDeps = Seq(d) | ||
} | ||
object d extends JavaModule { | ||
override def moduleDeps = Seq(b) | ||
} | ||
} | ||
object e extends JavaModule { | ||
override def moduleDeps = Seq(b) | ||
} | ||
object f extends JavaModule { | ||
override def compileModuleDeps = Seq(f) | ||
} | ||
} | ||
|
||
def workspaceTest[T](m: TestUtil.BaseModule)(t: TestEvaluator => T)(implicit tp: TestPath): T = { | ||
val eval = new TestEvaluator(m) | ||
os.remove.all(m.millSourcePath) | ||
os.remove.all(eval.outPath) | ||
os.makeDir.all(m.millSourcePath / os.up) | ||
t(eval) | ||
} | ||
|
||
override def tests: Tests = Tests { | ||
test("moduleDeps") { | ||
test("self-reference") - workspaceTest(CycleBase) { eval => | ||
val ex = intercept[BuildScriptException] { | ||
eval.apply(CycleBase.a.compile) | ||
} | ||
assert(ex.getMessage.contains("a.moduleDeps: cycle detected: a -> a")) | ||
} | ||
test("cycle-in-deps") - workspaceTest(CycleBase) { eval => | ||
val ex = intercept[BuildScriptException] { | ||
eval.apply(CycleBase.e.compile) | ||
} | ||
assert(ex.getMessage.contains("e.moduleDeps: cycle detected: b -> b.c -> b.d -> b")) | ||
} | ||
} | ||
test("compileModuleDeps") { | ||
test("self-reference") - workspaceTest(CycleBase) { eval => | ||
val ex = intercept[BuildScriptException] { | ||
eval.apply(CycleBase.f.compile) | ||
} | ||
assert(ex.getMessage.contains("f.compileModuleDeps: cycle detected: f -> f")) | ||
} | ||
} | ||
} | ||
} |