diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-10 00:21:42 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-10 07:45:35 -0800 |
commit | fb7d39ad7f6dee1580bd30ec96ae494d97f146f1 (patch) | |
tree | 0c66bac628d5610b98854b0fde410973322c6c5b /main/test/src | |
parent | 9fe80b1f7e45e9cf6dc1f2a6586c4285e3e6103e (diff) | |
download | mill-fb7d39ad7f6dee1580bd30ec96ae494d97f146f1.tar.gz mill-fb7d39ad7f6dee1580bd30ec96ae494d97f146f1.tar.bz2 mill-fb7d39ad7f6dee1580bd30ec96ae494d97f146f1.zip |
fix tests
Diffstat (limited to 'main/test/src')
-rw-r--r-- | main/test/src/mill/main/MainTests.scala | 24 | ||||
-rw-r--r-- | main/test/src/mill/util/ParseArgsTest.scala | 23 | ||||
-rw-r--r-- | main/test/src/mill/util/ScriptTestSuite.scala | 5 |
3 files changed, 27 insertions, 25 deletions
diff --git a/main/test/src/mill/main/MainTests.scala b/main/test/src/mill/main/MainTests.scala index d4b90b2f..87b3f7ab 100644 --- a/main/test/src/mill/main/MainTests.scala +++ b/main/test/src/mill/main/MainTests.scala @@ -27,8 +27,8 @@ object MainTests extends TestSuite{ 'single - { val check = MainTests.check(singleton) _ 'pos - check("single", Right(Seq(_.single))) - 'neg1 - check("doesntExist", Left("Cannot resolve task doesntExist")) - 'neg2 - check("single.doesntExist", Left("Cannot resolve module single")) + 'neg1 - check("doesntExist", Left("Cannot resolve doesntExist")) + 'neg2 - check("single.doesntExist", Left("Cannot resolve single")) 'neg3 - check("", Left("Selector cannot be empty")) } 'nested - { @@ -36,10 +36,10 @@ object MainTests extends TestSuite{ 'pos1 - check("single", Right(Seq(_.single))) 'pos2 - check("nested.single", Right(Seq(_.nested.single))) 'pos3 - check("classInstance.single", Right(Seq(_.classInstance.single))) - 'neg1 - check("doesntExist", Left("Cannot resolve task doesntExist")) - 'neg2 - check("single.doesntExist", Left("Cannot resolve module single")) - 'neg3 - check("nested.doesntExist", Left("Cannot resolve task nested.doesntExist")) - 'neg4 - check("classInstance.doesntExist", Left("Cannot resolve task classInstance.doesntExist")) + 'neg1 - check("doesntExist", Left("Cannot resolve doesntExist")) + 'neg2 - check("single.doesntExist", Left("Cannot resolve single")) + 'neg3 - check("nested.doesntExist", Left("Cannot resolve nested.doesntExist")) + 'neg4 - check("classInstance.doesntExist", Left("Cannot resolve classInstance.doesntExist")) 'wildcard - check( "_.single", Right(Seq( @@ -49,11 +49,11 @@ object MainTests extends TestSuite{ ) 'wildcardNeg - check( "_._.single", - Left("Cannot resolve module _") + Left("Cannot resolve _") ) 'wildcardNeg2 - check( "_._.__", - Left("Cannot resolve module _") + Left("Cannot resolve _") ) 'wildcard2 - check( "__.single", @@ -78,9 +78,9 @@ object MainTests extends TestSuite{ val check = MainTests.check(singleCross) _ 'pos1 - check("cross[210].suffix", Right(Seq(_.cross("210").suffix))) 'pos2 - check("cross[211].suffix", Right(Seq(_.cross("211").suffix))) - 'neg1 - check("cross[210].doesntExist", Left("Cannot resolve task cross[210].doesntExist")) - 'neg2 - check("cross[doesntExist].doesntExist", Left("Cannot resolve cross cross[doesntExist]")) - 'neg2 - check("cross[doesntExist].suffix", Left("Cannot resolve cross cross[doesntExist]")) + 'neg1 - check("cross[210].doesntExist", Left("Cannot resolve cross[210].doesntExist")) + 'neg2 - check("cross[doesntExist].doesntExist", Left("Cannot resolve cross[doesntExist]")) + 'neg2 - check("cross[doesntExist].suffix", Left("Cannot resolve cross[doesntExist]")) 'wildcard - check( "cross[_].suffix", Right(Seq( @@ -111,7 +111,7 @@ object MainTests extends TestSuite{ 'wildcard - { 'labelNeg - check( "_.suffix", - Left("Cannot resolve module _") + Left("Cannot resolve _.suffix") ) 'labelPos - check( "__.suffix", diff --git a/main/test/src/mill/util/ParseArgsTest.scala b/main/test/src/mill/util/ParseArgsTest.scala index 3c12525e..caa1afec 100644 --- a/main/test/src/mill/util/ParseArgsTest.scala +++ b/main/test/src/mill/util/ParseArgsTest.scala @@ -1,6 +1,6 @@ package mill.util -import mill.define.Segment +import mill.define.{Segment, Segments} import mill.define.Segment.{Cross, Label} import utest._ @@ -43,20 +43,19 @@ object ParseArgsTest extends TestSuite { multiSelect = false ) 'multiSelectors - check( - input = Seq("--all", "core.jar", "core.docsJar", "core.sourcesJar"), + input = Seq("core.jar", "core.docsJar", "core.sourcesJar"), expectedSelectors = Seq("core.jar", "core.docsJar", "core.sourcesJar"), expectedArgs = Seq.empty, multiSelect = true ) 'multiSelectorsSeq - check( - input = Seq("--seq", "core.jar", "core.docsJar", "core.sourcesJar"), + input = Seq("core.jar", "core.docsJar", "core.sourcesJar"), expectedSelectors = Seq("core.jar", "core.docsJar", "core.sourcesJar"), expectedArgs = Seq.empty, multiSelect = true ) 'multiSelectorsWithArgs - check( - input = Seq("--all", - "core.compile", + input = Seq("core.compile", "application.runMain", "--", "Main", @@ -67,8 +66,7 @@ object ParseArgsTest extends TestSuite { multiSelect = true ) 'multiSelectorsWithArgsWithAllInArgs - check( - input = Seq("--all", - "core.compile", + input = Seq("core.compile", "application.runMain", "--", "Main", @@ -230,10 +228,15 @@ object ParseArgsTest extends TestSuite { multiSelect = true ) 'multiSelectorsBraceExpansionWithoutAll - { - assert( - ParseArgs(Seq("{core,application}.compile"), multiSelect = false) == Left( - "Please use --all flag to run multiple tasks") + val res = ParseArgs(Seq("{core,application}.compile"), multiSelect = false) + val expected = Right( + List( + None -> Segments(Label("core"), Label("compile")), + None -> Segments(Label("application"), Label("compile")) + ), + Nil ) + assert(res == expected) } 'multiSelectorsWithoutAllAsSingle - check( // this is how it works when we pass multiple tasks without --all flag diff --git a/main/test/src/mill/util/ScriptTestSuite.scala b/main/test/src/mill/util/ScriptTestSuite.scala index a613d1dc..0d1ff43a 100644 --- a/main/test/src/mill/util/ScriptTestSuite.scala +++ b/main/test/src/mill/util/ScriptTestSuite.scala @@ -3,7 +3,6 @@ package mill.util import java.io.{ByteArrayInputStream, ByteArrayOutputStream, PrintStream} import ammonite.ops._ -import mill.util.ParseArgs import utest._ abstract class ScriptTestSuite extends TestSuite{ @@ -11,8 +10,8 @@ abstract class ScriptTestSuite extends TestSuite{ def scriptSourcePath: Path val workspacePath = pwd / 'target / 'workspace / workspaceSlug - val stdOutErr = new PrintStream(new ByteArrayOutputStream()) -// val stdOutErr = new PrintStream(System.out) +// val stdOutErr = new PrintStream(new ByteArrayOutputStream()) + val stdOutErr = new PrintStream(System.out) val stdIn = new ByteArrayInputStream(Array()) val runner = new mill.main.MainRunner( ammonite.main.Cli.Config(wd = workspacePath), |