Skip to content

Commit

Permalink
Merge #169
Browse files Browse the repository at this point in the history
169: Dedup duplicate targets r=taiki-e a=taiki-e

Addresses #167 (comment)

Co-authored-by: Taiki Endo <te316e89@gmail.com>
  • Loading branch information
bors[bot] and taiki-e authored Sep 26, 2022
2 parents c26f56c + 0a1d3e3 commit 435be75
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 42 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ members = ["tests/auxiliary/build-info"]
anyhow = "1.0.34"
atty = "0.2.11"
ctrlc = { version = "3.1.4", features = ["termination"] }
indexmap = { version = "1.5.2", features = ["std"] }
lexopt = "0.2"
serde_json = "1"
termcolor = "1.1"
Expand Down
9 changes: 6 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{
};

use anyhow::{bail, format_err, Result};
use indexmap::IndexSet;
use lexopt::{
Arg::{Long, Short, Value},
ValueExt,
Expand Down Expand Up @@ -153,7 +154,7 @@ impl Args {
let mut verbose = 0;
let mut no_default_features = false;
let mut all_features = false;
let mut target = vec![];
let mut target = IndexSet::new();

let mut parser = lexopt::Parser::from_args(args);
let mut next_flag: Option<OwnedFlag> = None;
Expand Down Expand Up @@ -207,7 +208,9 @@ impl Args {

match arg {
Long("color") => parse_opt!(color, true),
Long("target") => target.push(parser.value()?.parse()?),
Long("target") => {
target.insert(parser.value()?.parse()?);
}

Long("manifest-path") => parse_opt!(manifest_path, false),
Long("depth") => parse_opt!(depth, false),
Expand Down Expand Up @@ -566,7 +569,7 @@ impl Args {
features,

no_default_features,
target,
target: target.into_iter().collect(),
})
}
}
Expand Down
105 changes: 66 additions & 39 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1308,57 +1308,84 @@ fn default_feature_behavior() {
#[cfg_attr(windows, ignore)] // rustup bug: https://github.com/rust-lang/rustup/issues/3036
#[test]
fn version_range() {
cargo_hack(["check", "--version-range", "1.58..1.59"]).assert_success("real").stderr_contains(
cargo_hack(["check", "--version-range", "1.63..1.64"]).assert_success("real").stderr_contains(
"
running `cargo +1.58 check` on real (1/2)
running `cargo +1.59 check` on real (2/2)
running `cargo +1.63 check` on real (1/2)
running `cargo +1.64 check` on real (2/2)
",
);

cargo_hack(["check", "--version-range", "1.58..1.59", "--target", TARGET])
cargo_hack(["check", "--version-range", "1.63..1.64", "--target", TARGET])
.assert_success("real")
.stderr_contains(format!(
"
running `cargo +1.58 check --target {0}` on real (1/2)
running `cargo +1.59 check --target {0}` on real (2/2)
running `cargo +1.63 check --target {0}` on real (1/2)
running `cargo +1.64 check --target {0}` on real (2/2)
",
TARGET
));
}

if cfg!(target_os = "linux") {
cargo_hack([
"check",
"--version-range",
"1.58..1.59",
"--target",
"x86_64-unknown-linux-musl",
])
.assert_success("real")
.stderr_contains(
"
running `cargo +1.58 check --target x86_64-unknown-linux-musl` on real (1/2)
running `cargo +1.59 check --target x86_64-unknown-linux-musl` on real (2/2)
",
);
#[cfg_attr(windows, ignore)] // rustup bug: https://github.com/rust-lang/rustup/issues/3036
#[test]
fn multitarget() {
let target_suffix = if cfg!(target_os = "linux") && cfg!(target_env = "gnu") {
"-unknown-linux-gnu"
} else if cfg!(target_os = "macos") {
"-apple-darwin"
} else {
unimplemented!()
};

cargo_hack([
"check",
"--version-range",
"1.63..1.64",
"--target",
"x86_64-unknown-linux-gnu",
"--target",
"x86_64-unknown-linux-musl",
])
.assert_success("real")
.stderr_contains(
"
running `cargo +1.63 check --target x86_64-unknown-linux-gnu` on real (1/3)
running `cargo +1.63 check --target x86_64-unknown-linux-musl` on real (2/3)
running `cargo +1.64 check --target x86_64-unknown-linux-gnu --target x86_64-unknown-linux-musl` on real (3/3)
",
);
}
cargo_hack([
"check",
"--version-range",
"1.63..1.64",
"--target",
&format!("aarch64{target_suffix}"),
])
.assert_success("real")
.stderr_contains(format!(
"
running `cargo +1.63 check --target aarch64{target_suffix}` on real (1/2)
running `cargo +1.64 check --target aarch64{target_suffix}` on real (2/2)
"
));

cargo_hack([
"check",
"--version-range",
"1.63..1.64",
"--target",
&format!("x86_64{target_suffix}"),
"--target",
&format!("aarch64{target_suffix}"),
])
.assert_success("real")
.stderr_contains(format!(
"
running `cargo +1.63 check --target x86_64{target_suffix}` on real (1/3)
running `cargo +1.63 check --target aarch64{target_suffix}` on real (2/3)
running `cargo +1.64 check --target x86_64{target_suffix} --target aarch64{target_suffix}` on real (3/3)
",
));

cargo_hack([
"check",
"--version-range",
"1.63..1.64",
"--target",
&format!("x86_64{target_suffix}"),
"--target",
&format!("x86_64{target_suffix}"),
])
.assert_success("real")
.stderr_contains(format!(
"
running `cargo +1.63 check --target x86_64{target_suffix}` on real (1/2)
running `cargo +1.64 check --target x86_64{target_suffix}` on real (2/2)
",
));
}

#[cfg_attr(windows, ignore)] // rustup bug: https://github.com/rust-lang/rustup/issues/3036
Expand Down

0 comments on commit 435be75

Please sign in to comment.