Neater error message. Tests now check the cycle is output.
authorGiles Cope <gilescope@gmail.com>
Tue, 6 Mar 2018 09:30:37 +0000 (09:30 +0000)
committerGiles Cope <gilescope@gmail.com>
Tue, 6 Mar 2018 09:30:37 +0000 (09:30 +0000)
src/cargo/core/resolver/mod.rs
tests/testsuite/build.rs

index 402dd42a652d99088f3490a2887dd0922d829a18..234646b3a4a6f27b85885061aeec9bde5fe185bc 100644 (file)
@@ -1491,8 +1491,12 @@ fn check_cycles(resolve: &Resolve, activations: &Activations)
                  -> CargoResult<()> {
         // See if we visited ourselves
         if !visited.insert(id) {
-            bail!("cyclic package dependency: package `{}` depends on itself. Cycle (not in order): {:#?}",
-                  id, visited);
+            let mut cycle = String::new();
+            for package_id in visited.iter() {
+                 cycle += &format!("\n    {}", package_id);
+            }
+            bail!("cyclic package dependency: package `{}` depends on itself. Cycle (not in order):{}",
+                  id, cycle);
         }
 
         // If we've already checked this node no need to recurse again as we'll
index d7049befaa06a7fd418e61cbb960340ccf4a44cb..f7f2d532bcebba3508041804ce497522a59b6029 100644 (file)
@@ -1532,7 +1532,9 @@ fn self_dependency() {
     assert_that(p.cargo("build"),
                 execs().with_status(101)
                        .with_stderr_contains("\
-[ERROR] cyclic package dependency: package `test v0.0.0 ([..])` depends on itself[..]"));
+[ERROR] cyclic package dependency: package `test v0.0.0 ([..])` depends on itself. Cycle (not in order):
+    test v0.0.0 ([..][/]foo)
+"));
 }
 
 #[test]
@@ -2653,7 +2655,10 @@ fn cyclic_deps_rejected() {
                 execs().with_status(101)
                        .with_stderr_contains("\
 [ERROR] cyclic package dependency: package `a v0.0.1 ([..]")
-                       .with_stderr_contains("[..]depends on itself[..]"));
+                       .with_stderr_contains("[..]depends on itself[..]")
+                       .with_stderr_contains("    foo v0.0.1 ([..][/]foo)")
+                       .with_stderr_contains("    a v0.0.1 ([..][/]a)"));
+
 }
 
 #[test]