diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-26 09:20:14 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-26 09:20:14 -0800 |
commit | 39f38d4fd354ec70d4dcaf52a8804c8143b1c3f0 (patch) | |
tree | 24edca9345f5b46e436d7bfd0d1e14714abf73b2 /core/src/test | |
parent | 4306f94c080f48bb8e4333af06ea8bc158beb219 (diff) | |
download | mill-39f38d4fd354ec70d4dcaf52a8804c8143b1c3f0.tar.gz mill-39f38d4fd354ec70d4dcaf52a8804c8143b1c3f0.tar.bz2 mill-39f38d4fd354ec70d4dcaf52a8804c8143b1c3f0.zip |
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
Diffstat (limited to 'core/src/test')
-rw-r--r-- | core/src/test/scala/mill/discover/DiscoveredTests.scala | 14 | ||||
-rw-r--r-- | core/src/test/scala/mill/util/TestGraphs.scala | 11 |
2 files changed, 24 insertions, 1 deletions
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 = |