make sure cashing works whether there is an answer or not
authorEh2406 <YeomanYaacov@gmail.com>
Mon, 12 Mar 2018 21:36:02 +0000 (17:36 -0400)
committerEh2406 <YeomanYaacov@gmail.com>
Mon, 12 Mar 2018 21:36:02 +0000 (17:36 -0400)
tests/testsuite/resolve.rs

index 8c96da9dd357d13b2e49daa37175e3e6fc980049..86b7d86c551d1683e93d59a7b9f0c1a16d688b4b 100644 (file)
@@ -470,13 +470,15 @@ fn resolving_with_constrained_sibling_backtrack_parent() {
 
 #[test]
 fn resolving_with_many_equivalent_backtracking() {
-    let mut reglist = vec![
-        pkg!(("level0", "1.0.0")),
-    ];
+    let mut reglist = Vec::new();
 
     const DEPTH: usize = 200;
     const BRANCHING_FACTOR: usize = 100;
 
+    // Each level depends on the next but the last level does not exist.
+    // Without cashing we need to test every path to the last level O(BRANCHING_FACTOR ^ DEPTH)
+    // and this test will time out. With cashing we need to discover that none of these
+    // can be activated O(BRANCHING_FACTOR * DEPTH)
     for l in 0..DEPTH {
         let name = format!("level{}", l);
         let next = format!("level{}", l + 1);
@@ -486,6 +488,18 @@ fn resolving_with_many_equivalent_backtracking() {
         }
     }
 
+    let reg = registry(reglist.clone());
+
+    let res = resolve(&pkg_id("root"), vec![
+        dep_req("level0", "*"),
+    ], &reg);
+
+    assert!(res.is_err());
+
+    // It is easy to write code that quickly returns an error.
+    // Lets make sure we can find a good answer if it is there.
+    reglist.push(pkg!(("level0", "1.0.0")));
+
     let reg = registry(reglist);
 
     let res = resolve(&pkg_id("root"), vec![