Skip to content

Commit

Permalink
delete and change more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
heisen-li committed May 13, 2024
1 parent 688f37c commit feda71e
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 165 deletions.
7 changes: 2 additions & 5 deletions src/cargo/util/toml/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,11 +841,8 @@ fn configure(toml: &TomlTarget, target: &mut Target) -> CargoResult<()> {
Some(false) => RustdocScrapeExamples::Disabled,
Some(true) => RustdocScrapeExamples::Enabled,
})
.set_for_host(match toml.proc_macro() {
None => t2.for_host(),
Some(true) => true,
Some(false) => false,
});
.set_for_host(toml.proc_macro().unwrap_or_else(t2.for_host()));

if let Some(edition) = toml.edition.clone() {
target.set_edition(
edition
Expand Down
1 change: 0 additions & 1 deletion tests/testsuite/build_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2221,7 +2221,6 @@ fn transitive_dep_host() {
[lib]
name = "b"
plugin = true
[dependencies.a]
path = "../a"
Expand Down
2 changes: 0 additions & 2 deletions tests/testsuite/cross_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,6 @@ fn plugin_build_script_right_arch() {
[lib]
name = "foo"
plugin = true
"#,
)
.file("build.rs", "fn main() {}")
Expand All @@ -912,7 +911,6 @@ fn plugin_build_script_right_arch() {
.arg(cross_compile::alternate())
.with_stderr(
"\
[WARNING] unused manifest key: lib.plugin
[COMPILING] foo v0.0.1 ([..])
[RUNNING] `rustc [..] build.rs [..]`
[RUNNING] `[..]/build-script-build`
Expand Down
158 changes: 1 addition & 157 deletions tests/testsuite/rustflags.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
//! Tests for setting custom rustc flags.
use cargo_test_support::registry::Package;
use cargo_test_support::{
basic_lib_manifest, basic_manifest, paths, project, project_in_home, rustc_host,
};
use cargo_test_support::{basic_manifest, paths, project, project_in_home, rustc_host};
use std::fs;

#[cargo_test]
Expand Down Expand Up @@ -114,76 +112,6 @@ fn env_rustflags_build_script_dep() {
foo.cargo("check").env("RUSTFLAGS", "--cfg foo").run();
}

#[cargo_test]
fn env_rustflags_plugin() {
// RUSTFLAGS should be passed to rustc for plugins
// when --target is not specified.
// In this test if --cfg foo is not passed the build will fail.
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
[lib]
name = "foo"
plugin = true
"#,
)
.file(
"src/lib.rs",
r#"
fn main() { }
#[cfg(not(foo))]
fn main() { }
"#,
)
.build();

p.cargo("check").env("RUSTFLAGS", "--cfg foo").run();
}

#[cargo_test]
fn env_rustflags_plugin_dep() {
// RUSTFLAGS should be passed to rustc for plugins
// when --target is not specified.
// In this test if --cfg foo is not passed the build will fail.
let foo = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
[lib]
name = "foo"
plugin = true
[dependencies.bar]
path = "../bar"
"#,
)
.file("src/lib.rs", "fn foo() {}")
.build();
let _bar = project()
.at("bar")
.file("Cargo.toml", &basic_lib_manifest("bar"))
.file(
"src/lib.rs",
r#"
fn bar() { }
#[cfg(not(foo))]
fn bar() { }
"#,
)
.build();

foo.cargo("check").env("RUSTFLAGS", "--cfg foo").run();
}

#[cargo_test]
fn env_rustflags_normal_source_with_target() {
let p = project()
Expand Down Expand Up @@ -505,90 +433,6 @@ fn build_rustflags_build_script_dep() {
foo.cargo("check").run();
}

#[cargo_test]
fn build_rustflags_plugin() {
// RUSTFLAGS should be passed to rustc for plugins
// when --target is not specified.
// In this test if --cfg foo is not passed the build will fail.
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
[lib]
name = "foo"
plugin = true
"#,
)
.file(
"src/lib.rs",
r#"
fn main() { }
#[cfg(not(foo))]
fn main() { }
"#,
)
.file(
".cargo/config.toml",
r#"
[build]
rustflags = ["--cfg", "foo"]
"#,
)
.build();

p.cargo("check").run();
}

#[cargo_test]
fn build_rustflags_plugin_dep() {
// RUSTFLAGS should be passed to rustc for plugins
// when --target is not specified.
// In this test if --cfg foo is not passed the build will fail.
let foo = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
[lib]
name = "foo"
plugin = true
[dependencies.bar]
path = "../bar"
"#,
)
.file("src/lib.rs", "fn foo() {}")
.file(
".cargo/config.toml",
r#"
[build]
rustflags = ["--cfg", "foo"]
"#,
)
.build();
let _bar = project()
.at("bar")
.file("Cargo.toml", &basic_lib_manifest("bar"))
.file(
"src/lib.rs",
r#"
fn bar() { }
#[cfg(not(foo))]
fn bar() { }
"#,
)
.build();

foo.cargo("check").run();
}

#[cargo_test]
fn build_rustflags_normal_source_with_target() {
let p = project()
Expand Down

0 comments on commit feda71e

Please sign in to comment.