summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2017-11-18 13:59:40 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2017-11-18 13:59:40 -0800
commitfba1439021e9ad009157cc56dccc93b2e90b2c71 (patch)
tree4b11d081ea3ac3d0ecb1ac3df562f07013f9996e /core
parent3d083d5274cb31604ba04f81ea9e60f0fa3e94b8 (diff)
downloadmill-fba1439021e9ad009157cc56dccc93b2e90b2c71.tar.gz
mill-fba1439021e9ad009157cc56dccc93b2e90b2c71.tar.bz2
mill-fba1439021e9ad009157cc56dccc93b2e90b2c71.zip
Move some test cases that are testing `mill/discover/` code, into that package
Diffstat (limited to 'core')
-rw-r--r--core/src/test/scala/mill/define/GraphTests.scala79
-rw-r--r--core/src/test/scala/mill/discover/ConsistencyTests.scala54
-rw-r--r--core/src/test/scala/mill/discover/LabelingTests.scala53
3 files changed, 107 insertions, 79 deletions
diff --git a/core/src/test/scala/mill/define/GraphTests.scala b/core/src/test/scala/mill/define/GraphTests.scala
index cc7bd3c2..a83f7a7b 100644
--- a/core/src/test/scala/mill/define/GraphTests.scala
+++ b/core/src/test/scala/mill/define/GraphTests.scala
@@ -12,47 +12,6 @@ object GraphTests extends TestSuite{
val graphs = new TestGraphs()
import graphs._
- 'failConsistencyChecks - {
- // Make sure these fail because `def`s without `Cacher` will re-evaluate
- // each time, returning different sets of targets.
- //
- // Maybe later we can convert them into compile errors somehow
-
- val expected = List(List("down"), List("right"), List("left"), List("up"))
-
- 'diamond - {
- val inconsistent = Discovered.consistencyCheck(
- diamond,
- Discovered[diamond.type]
- )
-
- assert(inconsistent == Nil)
- }
- 'anonDiamond - {
- val inconsistent = Discovered.consistencyCheck(
- anonDiamond,
- Discovered[anonDiamond.type]
- )
-
- assert(inconsistent == Nil)
- }
-
- 'borkedCachedDiamond2 - {
- val inconsistent = Discovered.consistencyCheck(
- borkedCachedDiamond2,
- Discovered[borkedCachedDiamond2.type]
- )
- assert(inconsistent == expected)
- }
- 'borkedCachedDiamond3 - {
- val inconsistent = Discovered.consistencyCheck(
- borkedCachedDiamond3,
- Discovered[borkedCachedDiamond3.type]
- )
- assert(inconsistent == expected)
- }
- }
-
'topoSortedTransitiveTargets - {
def check(targets: OSet[Task[_]], expected: OSet[Task[_]]) = {
@@ -187,44 +146,6 @@ object GraphTests extends TestSuite{
)
}
- 'labeling - {
-
- def check[T: Discovered](base: T, t: Task[_], relPath: Option[String]) = {
-
-
- val names: Seq[(Task[_], Seq[String])] = Discovered.mapping(base).mapValues(_.segments).toSeq
- val nameMap = names.toMap
-
- val targetLabel = nameMap.get(t).map(_.mkString("."))
- assert(targetLabel == relPath)
- }
- 'singleton - check(singleton, singleton.single, Some("single"))
- 'pair - {
- check(pair, pair.up, Some("up"))
- check(pair, pair.down, Some("down"))
- }
-
- 'anonTriple - {
- check(anonTriple, anonTriple.up, Some("up"))
- check(anonTriple, anonTriple.down.inputs(0), None)
- check(anonTriple, anonTriple.down, Some("down"))
- }
-
- 'diamond - {
- check(diamond, diamond.up, Some("up"))
- check(diamond, diamond.left, Some("left"))
- check(diamond, diamond.right, Some("right"))
- check(diamond, diamond.down, Some("down"))
- }
-
- 'anonDiamond - {
- check(anonDiamond, anonDiamond.up, Some("up"))
- check(anonDiamond, anonDiamond.down.inputs(0), None)
- check(anonDiamond, anonDiamond.down.inputs(1), None)
- check(anonDiamond, anonDiamond.down, Some("down"))
- }
-
- }
}
}
diff --git a/core/src/test/scala/mill/discover/ConsistencyTests.scala b/core/src/test/scala/mill/discover/ConsistencyTests.scala
new file mode 100644
index 00000000..67e22595
--- /dev/null
+++ b/core/src/test/scala/mill/discover/ConsistencyTests.scala
@@ -0,0 +1,54 @@
+package mill.discover
+
+
+import mill.util.TestGraphs
+import utest._
+
+object ConsistencyTests extends TestSuite{
+
+ val tests = Tests{
+ val graphs = new TestGraphs()
+ import graphs._
+ 'failConsistencyChecks - {
+ // Make sure these fail because `def`s without `Cacher` will re-evaluate
+ // each time, returning different sets of targets.
+ //
+ // Maybe later we can convert them into compile errors somehow
+
+ val expected = List(List("down"), List("right"), List("left"), List("up"))
+
+ 'diamond - {
+ val inconsistent = Discovered.consistencyCheck(
+ diamond,
+ Discovered[diamond.type]
+ )
+
+ assert(inconsistent == Nil)
+ }
+ 'anonDiamond - {
+ val inconsistent = Discovered.consistencyCheck(
+ anonDiamond,
+ Discovered[anonDiamond.type]
+ )
+
+ assert(inconsistent == Nil)
+ }
+
+ 'borkedCachedDiamond2 - {
+ val inconsistent = Discovered.consistencyCheck(
+ borkedCachedDiamond2,
+ Discovered[borkedCachedDiamond2.type]
+ )
+ assert(inconsistent == expected)
+ }
+ 'borkedCachedDiamond3 - {
+ val inconsistent = Discovered.consistencyCheck(
+ borkedCachedDiamond3,
+ Discovered[borkedCachedDiamond3.type]
+ )
+ assert(inconsistent == expected)
+ }
+ }
+
+ }
+}
diff --git a/core/src/test/scala/mill/discover/LabelingTests.scala b/core/src/test/scala/mill/discover/LabelingTests.scala
new file mode 100644
index 00000000..a37c090c
--- /dev/null
+++ b/core/src/test/scala/mill/discover/LabelingTests.scala
@@ -0,0 +1,53 @@
+package mill.discover
+
+import mill.define.Task
+import mill.util.TestGraphs
+import utest._
+
+object LabelingTests extends TestSuite{
+
+ val tests = Tests{
+ val graphs = new TestGraphs()
+ import graphs._
+
+ 'labeling - {
+
+ def check[T: Discovered](base: T, t: Task[_], relPath: Option[String]) = {
+
+
+ val names: Seq[(Task[_], Seq[String])] = Discovered.mapping(base).mapValues(_.segments).toSeq
+ val nameMap = names.toMap
+
+ val targetLabel = nameMap.get(t).map(_.mkString("."))
+ assert(targetLabel == relPath)
+ }
+ 'singleton - check(singleton, singleton.single, Some("single"))
+ 'pair - {
+ check(pair, pair.up, Some("up"))
+ check(pair, pair.down, Some("down"))
+ }
+
+ 'anonTriple - {
+ check(anonTriple, anonTriple.up, Some("up"))
+ check(anonTriple, anonTriple.down.inputs(0), None)
+ check(anonTriple, anonTriple.down, Some("down"))
+ }
+
+ 'diamond - {
+ check(diamond, diamond.up, Some("up"))
+ check(diamond, diamond.left, Some("left"))
+ check(diamond, diamond.right, Some("right"))
+ check(diamond, diamond.down, Some("down"))
+ }
+
+ 'anonDiamond - {
+ check(anonDiamond, anonDiamond.up, Some("up"))
+ check(anonDiamond, anonDiamond.down.inputs(0), None)
+ check(anonDiamond, anonDiamond.down.inputs(1), None)
+ check(anonDiamond, anonDiamond.down, Some("down"))
+ }
+
+ }
+
+ }
+}