Add workspace root to metadata command.
authorEric Huss <eric@huss.org>
Sat, 13 Jan 2018 19:51:36 +0000 (11:51 -0800)
committerEric Huss <eric@huss.org>
Sun, 14 Jan 2018 05:26:05 +0000 (21:26 -0800)
Fixes #4933

src/cargo/ops/cargo_output_metadata.rs
tests/metadata.rs

index 1dca07451ca45d0d5b0080cffef4f142485add51..1b6da788f20d6e64db52a94af99a0acdd83119ef 100644 (file)
@@ -39,6 +39,7 @@ fn metadata_no_deps(ws: &Workspace,
         resolve: None,
         target_directory: ws.target_dir().display().to_string(),
         version: VERSION,
+        workspace_root: ws.root().display().to_string(),
     })
 }
 
@@ -66,6 +67,7 @@ fn metadata_full(ws: &Workspace,
         }),
         target_directory: ws.target_dir().display().to_string(),
         version: VERSION,
+        workspace_root: ws.root().display().to_string(),
     })
 }
 
@@ -76,6 +78,7 @@ pub struct ExportInfo {
     resolve: Option<MetadataResolve>,
     target_directory: String,
     version: u32,
+    workspace_root: String,
 }
 
 /// Newtype wrapper to provide a custom `Serialize` implementation.
index 214975c065e520fcee5e9e1b654dbb237f4565f1..71c3545ea95291751a1c6a44f82c2b4b8659c511 100644 (file)
@@ -51,7 +51,8 @@ fn cargo_metadata_simple() {
             "root": "foo 0.5.0 (path+file:[..]foo)"
         },
         "target_directory": "[..]foo[/]target",
-        "version": 1
+        "version": 1,
+        "workspace_root": "[..][/]foo"
     }"#));
 }
 
@@ -125,7 +126,8 @@ crate-type = ["lib", "staticlib"]
             "root": "foo 0.5.0 (path+file:[..]foo)"
         },
         "target_directory": "[..]foo[/]target",
-        "version": 1
+        "version": 1,
+        "workspace_root": "[..][/]foo"
     }"#));
 }
 
@@ -275,7 +277,8 @@ fn cargo_metadata_with_deps_and_version() {
             "root": "foo 0.5.0 (path+file:[..]foo)"
         },
         "target_directory": "[..]foo[/]target",
-        "version": 1
+        "version": 1,
+        "workspace_root": "[..][/]foo"
     }"#));
 }
 
@@ -337,7 +340,8 @@ name = "ex"
             ]
         },
         "target_directory": "[..]foo[/]target",
-        "version": 1
+        "version": 1,
+        "workspace_root": "[..][/]foo"
     }"#));
 }
 
@@ -400,7 +404,8 @@ crate-type = ["rlib", "dylib"]
             ]
         },
         "target_directory": "[..]foo[/]target",
-        "version": 1
+        "version": 1,
+        "workspace_root": "[..][/]foo"
     }"#));
 }
 
@@ -476,7 +481,8 @@ fn workspace_metadata() {
             "root": null
         },
         "target_directory": "[..]foo[/]target",
-        "version": 1
+        "version": 1,
+        "workspace_root": "[..][/]foo"
     }"#))
 }
 
@@ -540,7 +546,8 @@ fn workspace_metadata_no_deps() {
         "workspace_members": ["baz 0.5.0 (path+file:[..]baz)", "bar 0.5.0 (path+file:[..]bar)"],
         "resolve": null,
         "target_directory": "[..]foo[/]target",
-        "version": 1
+        "version": 1,
+        "workspace_root": "[..][/]foo"
     }"#))
 }
 
@@ -582,7 +589,8 @@ const MANIFEST_OUTPUT: &'static str=
     "workspace_members": [ "foo 0.5.0 (path+file:[..]foo)" ],
     "resolve": null,
     "target_directory": "[..]foo[/]target",
-    "version": 1
+    "version": 1,
+    "workspace_root": "[..][/]foo"
 }"#;
 
 #[test]