Skip to content

Commit

Permalink
Merge #164
Browse files Browse the repository at this point in the history
164: Handle empty string in parse_multi_opt r=taiki-e a=taiki-e

This allows 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.

Closes #163

Co-authored-by: Taiki Endo <[email protected]>
  • Loading branch information
bors[bot] and taiki-e authored Sep 4, 2022
2 parents 4b184f8 + ece506b commit f4c9d50
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}};
}

Expand Down
7 changes: 7 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

0 comments on commit f4c9d50

Please sign in to comment.