diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-18 13:49:16 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-18 13:49:16 -0800 |
commit | 3d083d5274cb31604ba04f81ea9e60f0fa3e94b8 (patch) | |
tree | a47e88939ea8530affceea9e4e3e6f3d103da470 /core | |
parent | a15ea041996029f406377ad7474b1f3e8154ab5d (diff) | |
download | mill-3d083d5274cb31604ba04f81ea9e60f0fa3e94b8.tar.gz mill-3d083d5274cb31604ba04f81ea9e60f0fa3e94b8.tar.bz2 mill-3d083d5274cb31604ba04f81ea9e60f0fa3e94b8.zip |
Add basic unit tests for `T.command` discovery
Diffstat (limited to 'core')
-rw-r--r-- | core/src/test/scala/mill/discover/DiscoveredTests.scala | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/core/src/test/scala/mill/discover/DiscoveredTests.scala b/core/src/test/scala/mill/discover/DiscoveredTests.scala index 843ec474..e9170967 100644 --- a/core/src/test/scala/mill/discover/DiscoveredTests.scala +++ b/core/src/test/scala/mill/discover/DiscoveredTests.scala @@ -2,6 +2,7 @@ package mill.discover import java.io.InputStreamReader +import mill.discover.Router.{ArgSig, EntryPoint} import utest._ import mill.{Module, T} import mill.util.TestUtil.test @@ -9,10 +10,12 @@ object DiscoveredTests extends TestSuite{ val tests = Tests{ - 'discovery{ + 'targets - { class CanNest extends Module{ val single = test() val invisible: Any = test() + val invisible2: mill.define.Task[Int] = test() + val invisible3: mill.define.Task[_] = test() } object outer { val single = test() @@ -50,6 +53,45 @@ object DiscoveredTests extends TestSuite{ ) assert(mapped.toSet == expected.toSet) } + + 'commands - { + object outer { + def hello() = T.command{ + println("Hello") + } + def echoPair(prefix: String, suffix: String) = T.command{ + println(prefix + " " + suffix) + } + object nested extends Module{ + def inner(x: Int) = T.command{ + println(x) + } + } + + } + + val discovered = Discovered[outer.type] + val outerCommands = discovered.mirror.commands + + assertMatch(outerCommands){case Seq( + EntryPoint("echoPair", + List(ArgSig("prefix", "String", None, None), ArgSig("suffix", "String", None, None)), + None, + false, + _ + ), + EntryPoint("hello", Nil, None, false, _) + ) =>} + + val innerCommands = discovered.mirror + .children + .flatMap(_._2.commands.asInstanceOf[Seq[EntryPoint[_]]]) + + assertMatch(innerCommands){case Seq( + EntryPoint("inner", _, None, false, _), + ) =>} + } + 'compileError - { 'unserializableTarget - { |