Repository: taiki-e/cargo-hack (language: rust)

Issue:
Warning about non-existing feature `''` if `--skip ''` is specified
I'm setting up some reusable workflows for my projects and as part of that need to pass in a parameterized `--skip` flag. Previously on 0.3.9 having this empty for projects that don't need to skip any features worked without any warnings, now on `0.5.17` this outputs a warning:

```
> cargo hack check --feature-powerset --skip ''
warning: specified feature `` not found in package `self-test`
info: running `cargo check --no-default-features` on self-test (1/1)
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
```

It would be nice if an empty string was considered the same as not passing the flag.


Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 96bb8b02..0937c98b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,9 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
 
 ## [Unreleased]
 
+- Allow empty strings in `--features` (`-F`), `--exclude-features` (`--skip`), `--include-features`.
+  Passing an empty string to them is now considered the same as not passing the flag. See [#163](https://github.com/taiki-e/cargo-hack/pull/163) for more.
+
 - Distribute prebuilt binaries for aarch64 Windows.
 
 ## [0.5.17] - 2022-08-12
diff --git a/src/cli.rs b/src/cli.rs
index b615a74d..169d3b6c 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -194,11 +194,8 @@ impl Args {
                     {
                         val = &val[1..val.len() - 1];
                     }
-                    if val.contains(',') {
-                        $v.extend(val.split(',').map(str::to_owned));
-                    } else {
-                        $v.extend(val.split(' ').map(str::to_owned));
-                    }
+                    let sep = if val.contains(',') { ',' } else { ' ' };
+                    $v.extend(val.split(sep).filter(|s| !s.is_empty()).map(str::to_owned));
                 }};
             }
 


Test patch:
diff --git a/tests/test.rs b/tests/test.rs
index 2968e088..2e1b5054 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -1414,3 +1414,10 @@ fn namespaced_features() {
             ",
         );
 }
+
+#[test]
+fn empty_string() {
+    cargo_hack(["check", "--each-feature", "--skip", ""])
+        .assert_success("real")
+        .stderr_not_contains("not found");
+}