From 39f38d4fd354ec70d4dcaf52a8804c8143b1c3f0 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sun, 26 Nov 2017 09:20:14 -0800 Subject: Refactor `build.sc` to pull out common `ScalaModule` code into a separate trait Also workaround a few scala-reflect bugs in `Discovered` and `Router` that were making this not-work --- core/src/test/scala/mill/discover/DiscoveredTests.scala | 14 +++++++++++++- core/src/test/scala/mill/util/TestGraphs.scala | 11 +++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'core/src/test/scala') diff --git a/core/src/test/scala/mill/discover/DiscoveredTests.scala b/core/src/test/scala/mill/discover/DiscoveredTests.scala index e606b2a9..98a54759 100644 --- a/core/src/test/scala/mill/discover/DiscoveredTests.scala +++ b/core/src/test/scala/mill/discover/DiscoveredTests.scala @@ -6,7 +6,7 @@ import mill.discover.Router.{ArgSig, EntryPoint} import utest._ import mill.{Module, T} import mill.discover.Mirror.Segment.Label -import mill.util.TestGraphs.nestedModule +import mill.util.TestGraphs.{TraitWithModuleObject, nestedModule} object DiscoveredTests extends TestSuite{ val tests = Tests{ @@ -36,6 +36,18 @@ object DiscoveredTests extends TestSuite{ assert(mapped.toSet == expected.toSet) } + 'traitWithModule - { + val discovered = Discovered[TraitWithModuleObject.type] + val mapped = discovered.targets(TraitWithModuleObject).map(x => x.segments -> x.target) + val expected = Seq( + ( + List(Label("TraitModule"), Label("testFramework")), + TraitWithModuleObject.TraitModule.testFramework + ) + ) + assert(mapped == expected) + } + 'commands - { object outer { def hello() = T.command{ diff --git a/core/src/test/scala/mill/util/TestGraphs.scala b/core/src/test/scala/mill/util/TestGraphs.scala index edea69a4..a69221da 100644 --- a/core/src/test/scala/mill/util/TestGraphs.scala +++ b/core/src/test/scala/mill/util/TestGraphs.scala @@ -167,6 +167,17 @@ object TestGraphs{ } + trait TraitWithModule extends Module{ outer => + object TraitModule extends Module{ + def testFramework = T{ "mill.UTestFramework" } + def test() = T.command{ ()/*donothing*/ } + } + } + + + // Make sure nested objects inherited from traits work + object TraitWithModuleObject extends TraitWithModule + object singleCross{ val cross = -- cgit v1.2.3