diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-02 23:25:42 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-02 23:25:42 -0800 |
commit | 932bc5c53bb380930e04765ae51c5a128f3b35fb (patch) | |
tree | 4b40b941b194134379a60f09e3624a59fe4bd285 /core/test | |
parent | 208b11c20643914547b9d643d1d4e6101cb17cd1 (diff) | |
download | mill-932bc5c53bb380930e04765ae51c5a128f3b35fb.tar.gz mill-932bc5c53bb380930e04765ae51c5a128f3b35fb.tar.bz2 mill-932bc5c53bb380930e04765ae51c5a128f3b35fb.zip |
Enforce that only one task in a group can use `T.ctx().dest` https://github.com/lihaoyi/mill/issues/62
Diffstat (limited to 'core/test')
-rw-r--r-- | core/test/src/mill/eval/FailureTests.scala | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/core/test/src/mill/eval/FailureTests.scala b/core/test/src/mill/eval/FailureTests.scala index 86eccb3f..d4758a12 100644 --- a/core/test/src/mill/eval/FailureTests.scala +++ b/core/test/src/mill/eval/FailureTests.scala @@ -1,6 +1,6 @@ package mill.eval - -import mill.util.TestEvaluator +import mill.T +import mill.util.{TestEvaluator, TestUtil} import ammonite.ops.pwd import utest._ import utest.framework.TestPath @@ -85,6 +85,21 @@ object FailureTests extends TestSuite{ expectedRawValues = Seq(Result.Skipped) ) } + 'multipleUsesOfDest - { + object build extends TestUtil.BaseModule { + // Using `T.ctx( ).dest` twice in a single task is ok + def left = T{ + T.ctx().dest.toString.length + T.ctx().dest.toString.length } + + // Using `T.ctx( ).dest` once in two different tasks is not ok + val task = T.task{ T.ctx().dest.toString.length } + def right = T{ task() + left() + T.ctx().dest.toString().length } + } + + val check = new TestEvaluator(build, workspace, pwd) + val Right(_) = check(build.left) + val Left(Result.Exception(e, _)) = check(build.right) + assert(e.getMessage.contains("`dest` can only be used in one place")) + } } } |