Skip to content

Commit

Permalink
Update tests to reflect -Zmultitarget stabilization
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Jul 16, 2022
1 parent 952627e commit 5d01364
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 84 deletions.
92 changes: 10 additions & 82 deletions tests/testsuite/multitarget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,6 @@

use cargo_test_support::{basic_manifest, cross_compile, project, rustc_host};

#[cargo_test]
fn double_target_rejected() {
let p = project()
.file("Cargo.toml", &basic_manifest("foo", "1.0.0"))
.file("src/main.rs", "fn main() {}")
.build();

p.cargo("build --target a --target b")
.with_stderr("[ERROR] specifying multiple `--target` flags requires `-Zmultitarget`")
.with_status(101)
.run();
}

#[cargo_test]
fn array_of_target_rejected_with_config() {
let p = project()
.file("Cargo.toml", &basic_manifest("foo", "1.0.0"))
.file("src/main.rs", "fn main() {}")
.file(
".cargo/config.toml",
r#"
[build]
target = ["a", "b"]
"#,
)
.build();

p.cargo("build")
.with_stderr(
"[ERROR] specifying an array in `build.target` config value requires `-Zmultitarget`",
)
.with_status(101)
.run();

p.change_file(
".cargo/config.toml",
r#"
[build]
target = ["a"]
"#,
);

p.cargo("build")
.with_stderr(
"[ERROR] specifying an array in `build.target` config value requires `-Zmultitarget`",
)
.with_status(101)
.run();
}

#[cargo_test]
fn simple_build() {
if cross_compile::disabled() {
Expand All @@ -64,12 +14,11 @@ fn simple_build() {
.file("src/main.rs", "fn main() {}")
.build();

p.cargo("build -Z multitarget")
p.cargo("build")
.arg("--target")
.arg(&t1)
.arg("--target")
.arg(&t2)
.masquerade_as_nightly_cargo(&["multitarget"])
.run();

assert!(p.target_bin(t1, "foo").is_file());
Expand All @@ -90,18 +39,14 @@ fn simple_build_with_config() {
".cargo/config.toml",
&format!(
r#"
[unstable]
multitarget = true
[build]
target = ["{t1}", "{t2}"]
"#
),
)
.build();

p.cargo("build")
.masquerade_as_nightly_cargo(&["multitarget"])
.run();
p.cargo("build").run();

assert!(p.target_bin(t1, "foo").is_file());
assert!(p.target_bin(t2, "foo").is_file());
Expand All @@ -119,12 +64,11 @@ fn simple_test() {
.file("src/lib.rs", "fn main() {}")
.build();

p.cargo("test -Z multitarget")
p.cargo("test")
.arg("--target")
.arg(&t1)
.arg("--target")
.arg(&t2)
.masquerade_as_nightly_cargo(&["multitarget"])
.with_stderr_contains(&format!("[RUNNING] [..]{}[..]", t1))
.with_stderr_contains(&format!("[RUNNING] [..]{}[..]", t2))
.run();
Expand All @@ -137,10 +81,9 @@ fn simple_run() {
.file("src/main.rs", "fn main() {}")
.build();

p.cargo("run -Z multitarget --target a --target b")
p.cargo("run --target a --target b")
.with_stderr("[ERROR] only one `--target` argument is supported")
.with_status(101)
.masquerade_as_nightly_cargo(&["multitarget"])
.run();
}

Expand All @@ -156,12 +99,11 @@ fn simple_doc() {
.file("src/lib.rs", "//! empty lib")
.build();

p.cargo("doc -Z multitarget")
p.cargo("doc")
.arg("--target")
.arg(&t1)
.arg("--target")
.arg(&t2)
.masquerade_as_nightly_cargo(&["multitarget"])
.run();

assert!(p.build_dir().join(&t1).join("doc/foo/index.html").is_file());
Expand All @@ -180,12 +122,11 @@ fn simple_check() {
.file("src/main.rs", "fn main() {}")
.build();

p.cargo("check -Z multitarget")
p.cargo("check")
.arg("--target")
.arg(&t1)
.arg("--target")
.arg(&t2)
.masquerade_as_nightly_cargo(&["multitarget"])
.run();
}

Expand All @@ -200,12 +141,11 @@ fn same_value_twice() {
.file("src/main.rs", "fn main() {}")
.build();

p.cargo("build -Z multitarget")
p.cargo("build")
.arg("--target")
.arg(&t)
.arg("--target")
.arg(&t)
.masquerade_as_nightly_cargo(&["multitarget"])
.run();

assert!(p.target_bin(t, "foo").is_file());
Expand All @@ -224,18 +164,14 @@ fn same_value_twice_with_config() {
".cargo/config.toml",
&format!(
r#"
[unstable]
multitarget = true
[build]
target = ["{t}", "{t}"]
"#
),
)
.build();

p.cargo("build")
.masquerade_as_nightly_cargo(&["multitarget"])
.run();
p.cargo("build").run();

assert!(p.target_bin(t, "foo").is_file());
}
Expand All @@ -253,18 +189,14 @@ fn works_with_config_in_both_string_or_list() {
".cargo/config.toml",
&format!(
r#"
[unstable]
multitarget = true
[build]
target = "{t}"
"#
),
)
.build();

p.cargo("build")
.masquerade_as_nightly_cargo(&["multitarget"])
.run();
p.cargo("build").run();

assert!(p.target_bin(t, "foo").is_file());

Expand All @@ -274,17 +206,13 @@ fn works_with_config_in_both_string_or_list() {
".cargo/config.toml",
&format!(
r#"
[unstable]
multitarget = true
[build]
target = ["{t}"]
"#
),
);

p.cargo("build")
.masquerade_as_nightly_cargo(&["multitarget"])
.run();
p.cargo("build").run();

assert!(p.target_bin(t, "foo").is_file());
}
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,8 @@ fn rustc_with_print_cfg_multiple_targets() {
.file("src/main.rs", r#"fn main() {} "#)
.build();

p.cargo("rustc -Z unstable-options -Z multitarget --target x86_64-pc-windows-msvc --target i686-unknown-linux-gnu --print cfg")
.masquerade_as_nightly_cargo(&["print", "multitarget"])
p.cargo("rustc -Z unstable-options --target x86_64-pc-windows-msvc --target i686-unknown-linux-gnu --print cfg")
.masquerade_as_nightly_cargo(&["print"])
.with_stdout_contains("debug_assertions")
.with_stdout_contains("target_arch=\"x86_64\"")
.with_stdout_contains("target_endian=\"little\"")
Expand Down

0 comments on commit 5d01364

Please sign in to comment.