Issue #5087
authorTimothy Bess <timbessmail@gmail.com>
Wed, 28 Feb 2018 02:34:04 +0000 (21:34 -0500)
committerman_nug <tbess@predikto.com>
Wed, 28 Feb 2018 02:37:40 +0000 (21:37 -0500)
* remove Workspace::current_manifest
* remove incorrect logging
* move empty check to Packages::into_package_id_specs
* add test case mentioned in issue

src/cargo/core/workspace.rs
src/cargo/ops/cargo_compile.rs
src/cargo/ops/cargo_doc.rs
tests/testsuite/build.rs

index 7a5ef6f3e3f96a2c9c9627b7df306b37f462bdd0..0ed855d060ebe3506274b17495054fe63d84e96e 100644 (file)
@@ -144,10 +144,6 @@ impl<'cfg> Workspace<'cfg> {
         Ok(ws)
     }
 
-    pub fn current_manifest(&self) -> &Path {
-        &self.current_manifest
-    }
-
     /// Creates a "temporary workspace" from one package which only contains
     /// that package.
     ///
index 7891ad304e298339e575cb328265dd5d34fa932a..4ff4e240d86399deab6a68804d7cda01284b1e34 100644 (file)
@@ -155,7 +155,12 @@ impl<'a> Packages<'a> {
                     .collect()
             }
         };
-        Ok(specs)
+        if specs.is_empty() {
+            bail!("Workspace contains no members to be compiled. \
+                   Be sure all workspace members haven't been excluded")
+        } else {
+            Ok(specs)
+        }
     }
 }
 
@@ -234,12 +239,6 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>,
                                             &specs)?;
     let (packages, resolve_with_overrides) = resolve;
 
-    if specs.is_empty() {
-        bail!("manifest path `{}` contains no package: The manifest is virtual, \
-               and the workspace has no members.",
-              ws.current_manifest().display())
-    }
-
     let to_builds = specs.iter().map(|p| {
         let pkgid = p.query(resolve_with_overrides.iter())?;
         let p = packages.get(pkgid)?;
index 9f21d1bd69c137b277da91c3aa918280e05b74f2..d747b42d0985c6e02b4a451725f89b65969b32c4 100644 (file)
@@ -22,12 +22,6 @@ pub fn doc(ws: &Workspace, options: &DocOptions) -> CargoResult<()> {
                                             &specs)?;
     let (packages, resolve_with_overrides) = resolve;
 
-    if specs.is_empty() {
-        bail!("manifest path `{}` contains no package: The manifest is virtual, \
-               and the workspace has no members.",
-              ws.current_manifest().display())
-    };
-
     let pkgs = specs.iter().map(|p| {
         let pkgid = p.query(resolve_with_overrides.iter())?;
         packages.get(pkgid)
index 2c15367e56fc3340a14f67ee0f30749d04c7f4fa..9dfafc133279443274e5d4aa0332646ec56db0e4 100644 (file)
@@ -137,6 +137,24 @@ fn incremental_config() {
             .with_status(0));
 }
 
+#[test]
+fn cargo_compile_with_workspace_excluded() {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [package]
+            name = "foo"
+            version = "0.1.0"
+            authors = []
+        "#)
+        .file("src/main.rs", "fn main() {}")
+        .build();
+
+    assert_that(
+        p.cargo("build").arg("--all").arg("--exclude").arg("foo"),
+        execs().with_stderr_does_not_contain("[..]virtual[..]")
+            .with_status(101));
+}
+
 #[test]
 fn cargo_compile_manifest_path() {
     let p = project("foo")