2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for the `cargo rustc` command.
|
|
|
|
|
2024-07-01 21:22:02 +00:00
|
|
|
use cargo_test_support::prelude::*;
|
|
|
|
use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, project, str};
|
2015-05-06 10:08:43 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn build_lib_for_foo() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-07-25 00:30:32 +00:00
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
2015-05-01 21:19:43 +00:00
|
|
|
|
2024-07-01 21:22:02 +00:00
|
|
|
p.cargo("rustc --lib -v").with_stderr_data(str![[r#"
|
|
|
|
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
|
|
|
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C debuginfo=2 [..]-C metadata=[..] [..]--out-dir [ROOT]/foo/target/debug/deps -L dependency=[ROOT]/foo/target/debug/deps`
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]]).run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-05-01 23:01:30 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn lib() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-07-25 00:30:32 +00:00
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
2015-05-01 23:01:30 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("rustc --lib -v -- -C debug-assertions=off")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
|
|
|
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C debuginfo=2 [..]-C debug-assertions=off[..]-C metadata=[..] [..]--out-dir [ROOT]/foo/target/debug/deps -L dependency=[ROOT]/foo/target/debug/deps`
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]])
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-05-01 23:01:30 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn build_main_and_allow_unstable_options() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-07-25 00:30:32 +00:00
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
2015-05-01 23:01:30 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("rustc -v --bin foo -- -C debug-assertions")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
|
|
|
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C debuginfo=2 [..]-C metadata=[..] --out-dir [ROOT]/foo/target/debug/deps -L dependency=[ROOT]/foo/target/debug/deps`
|
|
|
|
[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--crate-type bin --emit=[..]link[..]-C debuginfo=2 [..]-C debug-assertions[..]-C metadata=[..] --out-dir [ROOT]/foo/target/debug/deps -L dependency=[ROOT]/foo/target/debug/deps --extern foo=[ROOT]/foo/target/debug/deps/libfoo-[HASH].rlib`
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]])
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-05-02 14:30:16 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn fails_when_trying_to_build_main_and_lib_with_args() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-07-25 00:30:32 +00:00
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
2015-05-02 14:30:16 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("rustc -v -- -C debug-assertions")
|
|
|
|
.with_status(101)
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[ERROR] extra arguments to `rustc` can only be passed to one target, consider filtering
|
|
|
|
the package by passing, e.g., `--lib` or `--bin NAME` to specify a single target
|
|
|
|
|
|
|
|
"#]])
|
2018-08-28 09:20:03 +00:00
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn build_with_args_to_one_of_multiple_binaries() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-07-25 00:30:32 +00:00
|
|
|
.file("src/bin/foo.rs", "fn main() {}")
|
|
|
|
.file("src/bin/bar.rs", "fn main() {}")
|
|
|
|
.file("src/bin/baz.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("rustc -v --bin bar -- -C debug-assertions")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
|
|
|
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C debuginfo=2 [..]-C metadata=[..] --out-dir [..]`
|
|
|
|
[RUNNING] `rustc --crate-name bar --edition=2015 src/bin/bar.rs [..]--crate-type bin --emit=[..]link[..]-C debuginfo=2 [..]-C debug-assertions [..]`
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]])
|
2019-05-20 19:36:59 +00:00
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn fails_with_args_to_all_binaries() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-07-25 00:30:32 +00:00
|
|
|
.file("src/bin/foo.rs", "fn main() {}")
|
|
|
|
.file("src/bin/bar.rs", "fn main() {}")
|
|
|
|
.file("src/bin/baz.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("rustc -v -- -C debug-assertions")
|
|
|
|
.with_status(101)
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[ERROR] extra arguments to `rustc` can only be passed to one target, consider filtering
|
|
|
|
the package by passing, e.g., `--lib` or `--bin NAME` to specify a single target
|
|
|
|
|
|
|
|
"#]])
|
2018-08-28 09:20:03 +00:00
|
|
|
.run();
|
2021-11-18 15:57:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn fails_with_crate_type_to_multi_binaries() {
|
|
|
|
let p = project()
|
|
|
|
.file("src/bin/foo.rs", "fn main() {}")
|
|
|
|
.file("src/bin/bar.rs", "fn main() {}")
|
|
|
|
.file("src/bin/baz.rs", "fn main() {}")
|
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
|
|
|
|
2022-07-09 11:34:44 +00:00
|
|
|
p.cargo("rustc --crate-type lib")
|
2021-11-18 15:57:42 +00:00
|
|
|
.with_status(101)
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[ERROR] crate types to rustc can only be passed to one target, consider filtering
|
|
|
|
the package by passing, e.g., `--lib` or `--example` to specify a single target
|
|
|
|
|
|
|
|
"#]])
|
2021-11-18 15:57:42 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn fails_with_crate_type_to_multi_examples() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2024-02-22 17:37:03 +00:00
|
|
|
edition = "2015"
|
2021-11-18 15:57:42 +00:00
|
|
|
authors = []
|
|
|
|
|
|
|
|
[[example]]
|
|
|
|
name = "ex1"
|
|
|
|
crate-type = ["rlib"]
|
|
|
|
[[example]]
|
|
|
|
name = "ex2"
|
|
|
|
crate-type = ["rlib"]
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file("examples/ex1.rs", "")
|
|
|
|
.file("examples/ex2.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2022-07-09 11:34:44 +00:00
|
|
|
p.cargo("rustc -v --example ex1 --example ex2 --crate-type lib,cdylib")
|
2021-11-18 15:57:42 +00:00
|
|
|
.with_status(101)
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[ERROR] crate types to rustc can only be passed to one target, consider filtering
|
|
|
|
the package by passing, e.g., `--lib` or `--example` to specify a single target
|
|
|
|
|
|
|
|
"#]])
|
2021-11-18 15:57:42 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn fails_with_crate_type_to_binary() {
|
|
|
|
let p = project().file("src/bin/foo.rs", "fn main() {}").build();
|
|
|
|
|
2022-07-09 11:34:44 +00:00
|
|
|
p.cargo("rustc --crate-type lib")
|
2021-11-18 15:57:42 +00:00
|
|
|
.with_status(101)
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[ERROR] crate types can only be specified for libraries and example libraries.
|
|
|
|
Binaries, tests, and benchmarks are always the `bin` crate type
|
|
|
|
|
|
|
|
"#]])
|
2021-11-18 15:57:42 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn build_with_crate_type_for_foo() {
|
2022-02-13 09:33:30 +00:00
|
|
|
let p = project().file("src/lib.rs", "").build();
|
2021-11-18 15:57:42 +00:00
|
|
|
|
2022-07-09 11:34:44 +00:00
|
|
|
p.cargo("rustc -v --crate-type cdylib")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
|
|
|
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type cdylib [..]`
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]])
|
2021-11-18 15:57:42 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2022-02-13 09:42:12 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn build_with_crate_type_for_foo_with_deps() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
|
|
|
extern crate a;
|
|
|
|
pub fn foo() { a::hello(); }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2024-02-22 17:37:03 +00:00
|
|
|
edition = "2015"
|
2022-02-13 09:42:12 +00:00
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
a = { path = "a" }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("a/Cargo.toml", &basic_manifest("a", "0.1.0"))
|
|
|
|
.file("a/src/lib.rs", "pub fn hello() {}")
|
|
|
|
.build();
|
|
|
|
|
2022-07-09 11:34:44 +00:00
|
|
|
p.cargo("rustc -v --crate-type cdylib")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
2024-04-14 01:36:06 +00:00
|
|
|
[LOCKING] 2 packages to latest compatible versions
|
2024-07-01 21:22:02 +00:00
|
|
|
[COMPILING] a v0.1.0 ([ROOT]/foo/a)
|
|
|
|
[RUNNING] `rustc --crate-name a --edition=2015 a/src/lib.rs [..]--crate-type lib [..]`
|
|
|
|
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
|
|
|
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type cdylib [..]`
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]])
|
2022-02-13 09:42:12 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2021-11-18 15:57:42 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn build_with_crate_types_for_foo() {
|
2022-02-13 09:33:30 +00:00
|
|
|
let p = project().file("src/lib.rs", "").build();
|
2021-11-18 15:57:42 +00:00
|
|
|
|
2022-07-09 11:34:44 +00:00
|
|
|
p.cargo("rustc -v --crate-type lib,cdylib")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
|
|
|
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib,cdylib [..]`
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]])
|
2021-11-18 15:57:42 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn build_with_crate_type_to_example() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2024-02-22 17:37:03 +00:00
|
|
|
edition = "2015"
|
2021-11-18 15:57:42 +00:00
|
|
|
authors = []
|
|
|
|
|
|
|
|
[[example]]
|
|
|
|
name = "ex"
|
|
|
|
crate-type = ["rlib"]
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file("examples/ex.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2022-07-09 11:34:44 +00:00
|
|
|
p.cargo("rustc -v --example ex --crate-type cdylib")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
|
|
|
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib [..]`
|
|
|
|
[RUNNING] `rustc --crate-name ex --edition=2015 examples/ex.rs [..]--crate-type cdylib [..]`
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]])
|
2021-11-18 15:57:42 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn build_with_crate_types_to_example() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2024-02-22 17:37:03 +00:00
|
|
|
edition = "2015"
|
2021-11-18 15:57:42 +00:00
|
|
|
authors = []
|
|
|
|
|
|
|
|
[[example]]
|
|
|
|
name = "ex"
|
|
|
|
crate-type = ["rlib"]
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file("examples/ex.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2022-07-09 11:34:44 +00:00
|
|
|
p.cargo("rustc -v --example ex --crate-type lib,cdylib")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
|
|
|
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib [..]`
|
|
|
|
[RUNNING] `rustc --crate-name ex --edition=2015 examples/ex.rs [..]--crate-type lib,cdylib [..]`
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]])
|
2021-11-18 15:57:42 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn build_with_crate_types_to_one_of_multi_examples() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2024-02-22 17:37:03 +00:00
|
|
|
edition = "2015"
|
2021-11-18 15:57:42 +00:00
|
|
|
authors = []
|
|
|
|
|
|
|
|
[[example]]
|
|
|
|
name = "ex1"
|
|
|
|
crate-type = ["rlib"]
|
|
|
|
[[example]]
|
|
|
|
name = "ex2"
|
|
|
|
crate-type = ["rlib"]
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file("examples/ex1.rs", "")
|
|
|
|
.file("examples/ex2.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2022-07-09 11:34:44 +00:00
|
|
|
p.cargo("rustc -v --example ex1 --crate-type lib,cdylib")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
|
|
|
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib [..]`
|
|
|
|
[RUNNING] `rustc --crate-name ex1 --edition=2015 examples/ex1.rs [..]--crate-type lib,cdylib [..]`
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]])
|
2021-11-18 15:57:42 +00:00
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn build_with_args_to_one_of_multiple_tests() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2015-05-02 23:11:46 +00:00
|
|
|
.file("tests/foo.rs", r#" "#)
|
|
|
|
.file("tests/bar.rs", r#" "#)
|
|
|
|
.file("tests/baz.rs", r#" "#)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("rustc -v --test bar -- -C debug-assertions")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
|
|
|
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C debuginfo=2 [..]-C metadata=[..] --out-dir [..]`
|
|
|
|
[RUNNING] `rustc --crate-name bar --edition=2015 tests/bar.rs [..]--emit=[..]link[..]-C debuginfo=2 [..]-C debug-assertions --test[..]`
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]])
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn build_foo_with_bar_dependency() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let foo = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2024-02-22 17:37:03 +00:00
|
|
|
edition = "2015"
|
2020-09-27 00:59:58 +00:00
|
|
|
authors = []
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.bar]
|
|
|
|
path = "../bar"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "extern crate bar; fn main() { bar::baz() }")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
let _bar = project()
|
|
|
|
.at("bar")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2018-07-25 00:30:32 +00:00
|
|
|
.file("src/lib.rs", "pub fn baz() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
foo.cargo("rustc -v -- -C debug-assertions")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
2024-04-14 01:36:06 +00:00
|
|
|
[LOCKING] 2 packages to latest compatible versions
|
2024-07-01 21:22:02 +00:00
|
|
|
[COMPILING] bar v0.1.0 ([ROOT]/bar)
|
|
|
|
[RUNNING] `rustc --crate-name bar [..] -C debuginfo=2[..]`
|
|
|
|
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
|
|
|
[RUNNING] `rustc --crate-name foo [..] -C debuginfo=2 [..]-C debug-assertions [..]`
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]])
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn build_only_bar_dependency() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let foo = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2024-02-22 17:37:03 +00:00
|
|
|
edition = "2015"
|
2020-09-27 00:59:58 +00:00
|
|
|
authors = []
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.bar]
|
|
|
|
path = "../bar"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "extern crate bar; fn main() { bar::baz() }")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
let _bar = project()
|
|
|
|
.at("bar")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2018-07-25 00:30:32 +00:00
|
|
|
.file("src/lib.rs", "pub fn baz() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
foo.cargo("rustc -v -p bar -- -C debug-assertions")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
2024-04-14 01:36:06 +00:00
|
|
|
[LOCKING] 2 packages to latest compatible versions
|
2024-07-01 21:22:02 +00:00
|
|
|
[COMPILING] bar v0.1.0 ([ROOT]/bar)
|
2019-09-25 01:17:36 +00:00
|
|
|
[RUNNING] `rustc --crate-name bar [..]--crate-type lib [..] -C debug-assertions [..]`
|
2024-07-01 21:22:02 +00:00
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]])
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-09-12 21:32:35 +00:00
|
|
|
|
2024-07-01 21:22:02 +00:00
|
|
|
#[allow(deprecated)]
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-03-19 17:20:54 +00:00
|
|
|
fn targets_selected_default() {
|
2018-08-28 09:20:03 +00:00
|
|
|
let p = project().file("src/main.rs", "fn main() {}").build();
|
|
|
|
p.cargo("rustc -v")
|
2018-03-15 15:20:15 +00:00
|
|
|
// bin
|
2018-12-08 11:19:47 +00:00
|
|
|
.with_stderr_contains(
|
2024-02-28 19:22:00 +00:00
|
|
|
"[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--crate-type bin \
|
2019-04-26 20:53:51 +00:00
|
|
|
--emit=[..]link[..]",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
2018-03-15 15:20:15 +00:00
|
|
|
// bench
|
2018-12-08 11:19:47 +00:00
|
|
|
.with_stderr_does_not_contain(
|
2024-02-28 19:22:00 +00:00
|
|
|
"[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--emit=[..]link \
|
2018-12-08 11:19:47 +00:00
|
|
|
-C opt-level=3 --test [..]",
|
|
|
|
)
|
2018-03-15 15:20:15 +00:00
|
|
|
// unit test
|
2018-12-08 11:19:47 +00:00
|
|
|
.with_stderr_does_not_contain(
|
2024-02-28 19:22:00 +00:00
|
|
|
"[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--emit=[..]link \
|
2023-05-31 10:09:35 +00:00
|
|
|
-C debuginfo=2 [..]--test [..]",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-03-19 17:20:54 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-03-19 17:20:54 +00:00
|
|
|
fn targets_selected_all() {
|
2018-08-28 09:20:03 +00:00
|
|
|
let p = project().file("src/main.rs", "fn main() {}").build();
|
|
|
|
p.cargo("rustc -v --all-targets")
|
2024-07-01 21:22:02 +00:00
|
|
|
// bin and unit test
|
|
|
|
.with_stderr_data(
|
|
|
|
str![[r#"
|
|
|
|
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
|
|
|
[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--crate-type bin --emit=[..]link[..]`
|
|
|
|
[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]--emit[..]link[..] -C debuginfo=2 [..]--test [..]`
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]].unordered()
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-03-15 15:20:15 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn fail_with_multiple_packages() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let foo = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2024-02-22 17:37:03 +00:00
|
|
|
edition = "2015"
|
2020-09-27 00:59:58 +00:00
|
|
|
authors = []
|
2015-09-12 21:32:35 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.bar]
|
|
|
|
path = "../bar"
|
2015-09-12 21:32:35 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.baz]
|
|
|
|
path = "../baz"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-09-15 23:02:37 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
let _bar = project()
|
|
|
|
.at("bar")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
fn main() {
|
|
|
|
if cfg!(flag = "1") { println!("Yeah from bar!"); }
|
|
|
|
}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2015-09-15 23:02:37 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
let _baz = project()
|
|
|
|
.at("baz")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("baz", "0.1.0"))
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
fn main() {
|
|
|
|
if cfg!(flag = "1") { println!("Yeah from baz!"); }
|
|
|
|
}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2015-09-12 21:32:35 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
foo.cargo("rustc -v -p bar -p baz")
|
|
|
|
.with_status(1)
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[ERROR] the argument '--package [<SPEC>]' cannot be used multiple times
|
|
|
|
...
|
|
|
|
"#]])
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-12-17 18:10:59 +00:00
|
|
|
|
2020-10-04 15:28:01 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn fail_with_glob() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-10-09 23:44:57 +00:00
|
|
|
[workspace]
|
|
|
|
members = ["bar"]
|
|
|
|
"#,
|
2020-10-04 15:28:01 +00:00
|
|
|
)
|
|
|
|
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
|
|
|
.file("bar/src/lib.rs", "pub fn bar() { break_the_build(); }")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("rustc -p '*z'")
|
|
|
|
.with_status(101)
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[ERROR] Glob patterns on package selection are not supported.
|
|
|
|
|
|
|
|
"#]])
|
2020-10-04 15:28:01 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn rustc_with_other_profile() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2024-02-22 17:37:03 +00:00
|
|
|
edition = "2015"
|
2020-09-27 00:59:58 +00:00
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dev-dependencies]
|
|
|
|
a = { path = "a" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
#[cfg(test)] extern crate a;
|
2015-12-17 18:10:59 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
#[test]
|
|
|
|
fn foo() {}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("a/Cargo.toml", &basic_manifest("a", "0.1.0"))
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("a/src/lib.rs", "")
|
|
|
|
.build();
|
2015-12-17 18:10:59 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("rustc --profile test").run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2018-04-22 00:21:42 +00:00
|
|
|
|
2024-07-01 21:22:02 +00:00
|
|
|
#[allow(deprecated)]
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-04-22 00:21:42 +00:00
|
|
|
fn rustc_fingerprint() {
|
|
|
|
// Verify that the fingerprint includes the rustc args.
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-04-22 00:21:42 +00:00
|
|
|
.file("Cargo.toml", &basic_lib_manifest("foo"))
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("rustc -v -- -C debug-assertions")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[COMPILING] foo v0.5.0 ([ROOT]/foo)
|
|
|
|
[RUNNING] `rustc --crate-name foo [..]-C debug-assertions [..]`
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]])
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2018-04-22 00:21:42 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("rustc -v -- -C debug-assertions")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[FRESH] foo v0.5.0 ([ROOT]/foo)
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]])
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2018-08-28 09:20:03 +00:00
|
|
|
|
|
|
|
p.cargo("rustc -v")
|
|
|
|
.with_stderr_does_not_contain("-C debug-assertions")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[DIRTY] foo v0.5.0 ([ROOT]/foo): the profile configuration changed
|
|
|
|
[COMPILING] foo v0.5.0 ([ROOT]/foo)
|
|
|
|
[RUNNING] `rustc --crate-name foo [..]`
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]])
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2018-04-22 00:21:42 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("rustc -v")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(str![[r#"
|
|
|
|
[FRESH] foo v0.5.0 ([ROOT]/foo)
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]])
|
2018-12-08 11:19:47 +00:00
|
|
|
.run();
|
2018-04-22 00:21:42 +00:00
|
|
|
}
|
2018-05-09 00:23:28 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-05-09 00:23:28 +00:00
|
|
|
fn rustc_test_with_implicit_bin() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-05-09 00:23:28 +00:00
|
|
|
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
#[cfg(foo)]
|
|
|
|
fn f() { compile_fail!("Foo shouldn't be set."); }
|
|
|
|
fn main() {}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-05-09 00:23:28 +00:00
|
|
|
"tests/test1.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
#[cfg(not(foo))]
|
|
|
|
fn f() { compile_fail!("Foo should be set."); }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-05-09 00:23:28 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("rustc --test test1 -v -- --cfg foo")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stderr_data(
|
|
|
|
str![[r#"
|
|
|
|
[COMPILING] foo v0.5.0 ([ROOT]/foo)
|
|
|
|
[RUNNING] `rustc --crate-name test1 --edition=2015 tests/test1.rs [..] --cfg foo [..]`
|
|
|
|
[RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]`
|
|
|
|
...
|
|
|
|
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
|
|
|
|
|
|
|
"#]]
|
|
|
|
.unordered(),
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-05-09 00:23:28 +00:00
|
|
|
}
|
2021-02-22 00:35:33 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn rustc_with_print_cfg_single_target() {
|
|
|
|
let p = project()
|
|
|
|
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
|
|
|
.file("src/main.rs", r#"fn main() {} "#)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("rustc -Z unstable-options --target x86_64-pc-windows-msvc --print cfg")
|
2022-07-16 02:32:23 +00:00
|
|
|
.masquerade_as_nightly_cargo(&["print"])
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stdout_data(
|
|
|
|
str![[r#"
|
|
|
|
debug_assertions
|
|
|
|
target_arch="x86_64"
|
|
|
|
target_endian="little"
|
|
|
|
target_env="msvc"
|
|
|
|
target_family="windows"
|
|
|
|
target_os="windows"
|
|
|
|
target_pointer_width="64"
|
|
|
|
target_vendor="pc"
|
|
|
|
windows
|
|
|
|
...
|
|
|
|
"#]]
|
|
|
|
.unordered(),
|
|
|
|
)
|
2021-02-22 00:35:33 +00:00
|
|
|
.run();
|
|
|
|
}
|
2021-02-22 00:50:21 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn rustc_with_print_cfg_multiple_targets() {
|
|
|
|
let p = project()
|
|
|
|
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
|
|
|
.file("src/main.rs", r#"fn main() {} "#)
|
|
|
|
.build();
|
|
|
|
|
2022-06-17 11:53:12 +00:00
|
|
|
p.cargo("rustc -Z unstable-options --target x86_64-pc-windows-msvc --target i686-unknown-linux-gnu --print cfg")
|
|
|
|
.masquerade_as_nightly_cargo(&["print"])
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stdout_data(str![[r#"
|
|
|
|
debug_assertions
|
|
|
|
target_arch="x86"
|
|
|
|
target_endian="little"
|
|
|
|
target_env="gnu"
|
|
|
|
target_family="unix"
|
|
|
|
target_os="linux"
|
|
|
|
target_pointer_width="32"
|
|
|
|
target_vendor="unknown"
|
|
|
|
unix
|
|
|
|
debug_assertions
|
|
|
|
target_arch="x86_64"
|
|
|
|
target_endian="little"
|
|
|
|
target_env="msvc"
|
|
|
|
target_family="windows"
|
|
|
|
target_os="windows"
|
|
|
|
target_pointer_width="64"
|
|
|
|
target_vendor="pc"
|
|
|
|
windows
|
|
|
|
...
|
|
|
|
"#]].unordered())
|
2021-02-22 00:50:21 +00:00
|
|
|
.run();
|
|
|
|
}
|
2021-02-22 00:54:08 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn rustc_with_print_cfg_rustflags_env_var() {
|
|
|
|
let p = project()
|
|
|
|
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
|
|
|
.file("src/main.rs", r#"fn main() {} "#)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("rustc -Z unstable-options --target x86_64-pc-windows-msvc --print cfg")
|
2022-07-16 02:32:23 +00:00
|
|
|
.masquerade_as_nightly_cargo(&["print"])
|
2021-02-22 00:58:19 +00:00
|
|
|
.env("RUSTFLAGS", "-C target-feature=+crt-static")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stdout_data(
|
|
|
|
str![[r#"
|
|
|
|
debug_assertions
|
|
|
|
target_arch="x86_64"
|
|
|
|
target_endian="little"
|
|
|
|
target_env="msvc"
|
|
|
|
target_family="windows"
|
|
|
|
target_feature="crt-static"
|
|
|
|
target_os="windows"
|
|
|
|
target_pointer_width="64"
|
|
|
|
target_vendor="pc"
|
|
|
|
windows
|
|
|
|
...
|
|
|
|
"#]]
|
|
|
|
.unordered(),
|
|
|
|
)
|
2021-02-22 00:58:19 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn rustc_with_print_cfg_config_toml() {
|
|
|
|
let p = project()
|
|
|
|
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
2021-02-22 01:00:28 +00:00
|
|
|
.file(
|
|
|
|
".cargo/config.toml",
|
|
|
|
r#"
|
2021-02-22 00:58:19 +00:00
|
|
|
[target.x86_64-pc-windows-msvc]
|
|
|
|
rustflags = ["-C", "target-feature=+crt-static"]
|
2021-02-22 01:00:28 +00:00
|
|
|
"#,
|
|
|
|
)
|
2021-02-22 00:58:19 +00:00
|
|
|
.file("src/main.rs", r#"fn main() {} "#)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("rustc -Z unstable-options --target x86_64-pc-windows-msvc --print cfg")
|
2022-07-16 02:32:23 +00:00
|
|
|
.masquerade_as_nightly_cargo(&["print"])
|
2021-02-22 00:54:08 +00:00
|
|
|
.env("RUSTFLAGS", "-C target-feature=+crt-static")
|
2024-07-01 21:22:02 +00:00
|
|
|
.with_stdout_data(
|
|
|
|
str![[r#"
|
|
|
|
debug_assertions
|
|
|
|
target_arch="x86_64"
|
|
|
|
target_endian="little"
|
|
|
|
target_env="msvc"
|
|
|
|
target_family="windows"
|
|
|
|
target_feature="crt-static"
|
|
|
|
target_os="windows"
|
|
|
|
target_pointer_width="64"
|
|
|
|
target_vendor="pc"
|
|
|
|
windows
|
|
|
|
...
|
|
|
|
"#]]
|
|
|
|
.unordered(),
|
|
|
|
)
|
2021-02-22 00:54:08 +00:00
|
|
|
.run();
|
|
|
|
}
|