1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
package mill.eval
import mill.T
import mill.util.{TestEvaluator, TestUtil}
import ammonite.ops.{Path, pwd, rm}
import utest._
import utest.framework.TestPath
import mill.util.TestEvaluator.implicitDisover
object FailureTests extends TestSuite{
val tests = Tests{
val graphs = new mill.util.TestGraphs()
import graphs._
'evaluateSingle - {
val check = new TestEvaluator(singleton)
check.fail(
target = singleton.single,
expectedFailCount = 0,
expectedRawValues = Seq(Result.Success(0))
)
singleton.single.failure = Some("lols")
check.fail(
target = singleton.single,
expectedFailCount = 1,
expectedRawValues = Seq(Result.Failure("lols"))
)
singleton.single.failure = None
check.fail(
target = singleton.single,
expectedFailCount = 0,
expectedRawValues = Seq(Result.Success(0))
)
val ex = new IndexOutOfBoundsException()
singleton.single.exception = Some(ex)
check.fail(
target = singleton.single,
expectedFailCount = 1,
expectedRawValues = Seq(Result.Exception(ex, Nil))
)
}
'evaluatePair - {
val check = new TestEvaluator(pair)
check.fail(
pair.down,
expectedFailCount = 0,
expectedRawValues = Seq(Result.Success(0))
)
pair.up.failure = Some("lols")
check.fail(
pair.down,
expectedFailCount = 1,
expectedRawValues = Seq(Result.Skipped)
)
pair.up.failure = None
check.fail(
pair.down,
expectedFailCount = 0,
expectedRawValues = Seq(Result.Success(0))
)
pair.up.exception = Some(new IndexOutOfBoundsException())
check.fail(
pair.down,
expectedFailCount = 1,
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)
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"))
}
}
}
|