summaryrefslogtreecommitdiff
path: root/core/src/test/scala/forge/GraphTests.scala
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2017-11-05 14:12:48 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2017-11-05 14:12:48 -0800
commit44bd42587532755439fcdc175eb95604966bbea8 (patch)
tree400e2a16dc02f6b60ab9af30907fd7b3d96d053c /core/src/test/scala/forge/GraphTests.scala
parent2fd4c498cc005182ef65a20db30f461f0893508a (diff)
downloadmill-44bd42587532755439fcdc175eb95604966bbea8.tar.gz
mill-44bd42587532755439fcdc175eb95604966bbea8.tar.bz2
mill-44bd42587532755439fcdc175eb95604966bbea8.zip
Add a simple consistency checker on `Discovered` to test if any of the observable `Target`s in the given base are not being properly cached
Diffstat (limited to 'core/src/test/scala/forge/GraphTests.scala')
-rw-r--r--core/src/test/scala/forge/GraphTests.scala87
1 files changed, 48 insertions, 39 deletions
diff --git a/core/src/test/scala/forge/GraphTests.scala b/core/src/test/scala/forge/GraphTests.scala
index e608c877..1b542882 100644
--- a/core/src/test/scala/forge/GraphTests.scala
+++ b/core/src/test/scala/forge/GraphTests.scala
@@ -40,6 +40,54 @@ object GraphTests extends TestSuite{
assert(discovered == expected)
}
+ '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)
+ }
+ 'borkedCachedDiamond1 - {
+ val inconsistent = Discovered.consistencyCheck(
+ borkedCachedDiamond1,
+ Discovered[borkedCachedDiamond1.type]
+ )
+
+ assert(inconsistent == expected)
+ }
+ '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[Target[_]], expected: OSet[Target[_]]) = {
@@ -82,45 +130,6 @@ object GraphTests extends TestSuite{
defCachedDiamond.down
)
)
- 'borkedCachedDiamond - {
- // 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
- * - intercept[Throwable]{
- check(
- targets = OSet(borkedCachedDiamond1.down),
- expected = OSet(
- borkedCachedDiamond1.up,
- borkedCachedDiamond1.down.inputs(0),
- borkedCachedDiamond1.down.inputs(1),
- borkedCachedDiamond1.down
- )
- )
- }
- * - intercept[Throwable]{
- check(
- targets = OSet(borkedCachedDiamond2.down),
- expected = OSet(
- borkedCachedDiamond2.up,
- borkedCachedDiamond2.down.inputs(0),
- borkedCachedDiamond2.down.inputs(1),
- borkedCachedDiamond2.down
- )
- )
- }
- * - intercept[Throwable]{
- check(
- targets = OSet(borkedCachedDiamond3.down),
- expected = OSet(
- borkedCachedDiamond3.up,
- borkedCachedDiamond3.down.inputs(0),
- borkedCachedDiamond3.down.inputs(1),
- borkedCachedDiamond3.down
- )
- )
- }
- }
'bigSingleTerminal - {
val result = Evaluator.topoSortedTransitiveTargets(OSet(bigSingleTerminal.j)).values
TestUtil.checkTopological(result)