Update other tests to use cargo:: syntax

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
This commit is contained in:
hi-rustin 2023-06-11 16:02:03 +08:00
parent 9eeffbf0d7
commit ed9dc44f47
12 changed files with 73 additions and 67 deletions

View File

@ -4161,7 +4161,7 @@ fn compiler_json_error_format() {
)
.file(
"build.rs",
"fn main() { println!(\"cargo:rustc-cfg=xyz\") }",
"fn main() { println!(\"cargo::rustc-cfg=xyz\") }",
)
.file("src/main.rs", "fn main() { let unused = 92; }")
.file("bar/Cargo.toml", &basic_manifest("bar", "0.5.0"))
@ -5314,11 +5314,11 @@ fn deterministic_cfg_flags() {
"build.rs",
r#"
fn main() {
println!("cargo:rustc-cfg=cfg_a");
println!("cargo:rustc-cfg=cfg_b");
println!("cargo:rustc-cfg=cfg_c");
println!("cargo:rustc-cfg=cfg_d");
println!("cargo:rustc-cfg=cfg_e");
println!("cargo::rustc-cfg=cfg_a");
println!("cargo::rustc-cfg=cfg_b");
println!("cargo::rustc-cfg=cfg_c");
println!("cargo::rustc-cfg=cfg_d");
println!("cargo::rustc-cfg=cfg_e");
}
"#,
)

View File

@ -12,7 +12,7 @@ fn rerun_if_env_changes() {
"build.rs",
r#"
fn main() {
println!("cargo:rerun-if-env-changed=FOO");
println!("cargo::rerun-if-env-changed=FOO");
}
"#,
)
@ -66,8 +66,8 @@ fn rerun_if_env_or_file_changes() {
"build.rs",
r#"
fn main() {
println!("cargo:rerun-if-env-changed=FOO");
println!("cargo:rerun-if-changed=foo");
println!("cargo::rerun-if-env-changed=FOO");
println!("cargo::rerun-if-changed=foo");
}
"#,
)
@ -112,7 +112,7 @@ fn rerun_if_env_or_file_changes() {
fn rustc_bootstrap() {
let build_rs = r#"
fn main() {
println!("cargo:rustc-env=RUSTC_BOOTSTRAP=1");
println!("cargo::rustc-env=RUSTC_BOOTSTRAP=1");
}
"#;
let p = project()

View File

@ -16,7 +16,7 @@ fn build_script_extra_link_arg_bin() {
"build.rs",
r#"
fn main() {
println!("cargo:rustc-link-arg-bins=--this-is-a-bogus-flag");
println!("cargo::rustc-link-arg-bins=--this-is-a-bogus-flag");
}
"#,
)
@ -53,9 +53,9 @@ fn build_script_extra_link_arg_bin_single() {
"build.rs",
r#"
fn main() {
println!("cargo:rustc-link-arg-bins=--bogus-flag-all");
println!("cargo:rustc-link-arg-bin=foo=--bogus-flag-foo");
println!("cargo:rustc-link-arg-bin=bar=--bogus-flag-bar");
println!("cargo::rustc-link-arg-bins=--bogus-flag-all");
println!("cargo::rustc-link-arg-bin=foo=--bogus-flag-foo");
println!("cargo::rustc-link-arg-bin=bar=--bogus-flag-bar");
}
"#,
)
@ -81,7 +81,7 @@ fn build_script_extra_link_arg() {
"build.rs",
r#"
fn main() {
println!("cargo:rustc-link-arg=--this-is-a-bogus-flag");
println!("cargo::rustc-link-arg=--this-is-a-bogus-flag");
}
"#,
)
@ -102,7 +102,7 @@ fn link_arg_missing_target() {
.file("src/lib.rs", "")
.file(
"build.rs",
r#"fn main() { println!("cargo:rustc-link-arg-cdylib=--bogus"); }"#,
r#"fn main() { println!("cargo::rustc-link-arg-cdylib=--bogus"); }"#,
)
.build();
@ -112,28 +112,28 @@ fn link_arg_missing_target() {
// .with_status(101)
// .with_stderr("\
// [COMPILING] foo [..]
// error: invalid instruction `cargo:rustc-link-arg-cdylib` from build script of `foo v0.0.1 ([ROOT]/foo)`
// error: invalid instruction `cargo::rustc-link-arg-cdylib` from build script of `foo v0.0.1 ([ROOT]/foo)`
// The package foo v0.0.1 ([ROOT]/foo) does not have a cdylib target.
// ")
// .run();
p.change_file(
"build.rs",
r#"fn main() { println!("cargo:rustc-link-arg-bins=--bogus"); }"#,
r#"fn main() { println!("cargo::rustc-link-arg-bins=--bogus"); }"#,
);
p.cargo("check")
.with_status(101)
.with_stderr("\
[COMPILING] foo [..]
error: invalid instruction `cargo:rustc-link-arg-bins` from build script of `foo v0.0.1 ([ROOT]/foo)`
error: invalid instruction `cargo::rustc-link-arg-bins` from build script of `foo v0.0.1 ([ROOT]/foo)`
The package foo v0.0.1 ([ROOT]/foo) does not have a bin target.
")
.run();
p.change_file(
"build.rs",
r#"fn main() { println!("cargo:rustc-link-arg-bin=abc=--bogus"); }"#,
r#"fn main() { println!("cargo::rustc-link-arg-bin=abc=--bogus"); }"#,
);
p.cargo("check")
@ -141,7 +141,7 @@ The package foo v0.0.1 ([ROOT]/foo) does not have a bin target.
.with_stderr(
"\
[COMPILING] foo [..]
error: invalid instruction `cargo:rustc-link-arg-bin` from build script of `foo v0.0.1 ([ROOT]/foo)`
error: invalid instruction `cargo::rustc-link-arg-bin` from build script of `foo v0.0.1 ([ROOT]/foo)`
The package foo v0.0.1 ([ROOT]/foo) does not have a bin target with the name `abc`.
",
)
@ -149,7 +149,7 @@ The package foo v0.0.1 ([ROOT]/foo) does not have a bin target with the name `ab
p.change_file(
"build.rs",
r#"fn main() { println!("cargo:rustc-link-arg-bin=abc"); }"#,
r#"fn main() { println!("cargo::rustc-link-arg-bin=abc"); }"#,
);
p.cargo("check")
@ -157,8 +157,8 @@ The package foo v0.0.1 ([ROOT]/foo) does not have a bin target with the name `ab
.with_stderr(
"\
[COMPILING] foo [..]
error: invalid instruction `cargo:rustc-link-arg-bin=abc` from build script of `foo v0.0.1 ([ROOT]/foo)`
The instruction should have the form cargo:rustc-link-arg-bin=BIN=ARG
error: invalid instruction `cargo::rustc-link-arg-bin=abc` from build script of `foo v0.0.1 ([ROOT]/foo)`
The instruction should have the form cargo::rustc-link-arg-bin=BIN=ARG
",
)
.run();
@ -192,7 +192,7 @@ fn cdylib_link_arg_transitive() {
"bar/build.rs",
r#"
fn main() {
println!("cargo:rustc-link-arg-cdylib=--bogus");
println!("cargo::rustc-link-arg-cdylib=--bogus");
}
"#,
)
@ -204,7 +204,7 @@ fn cdylib_link_arg_transitive() {
[COMPILING] bar v1.0.0 [..]
[RUNNING] `rustc --crate-name build_script_build bar/build.rs [..]
[RUNNING] `[..]build-script-build[..]
warning: bar@1.0.0: cargo:rustc-link-arg-cdylib was specified in the build script of bar v1.0.0 \
warning: bar@1.0.0: cargo::rustc-link-arg-cdylib was specified in the build script of bar v1.0.0 \
([ROOT]/foo/bar), but that package does not contain a cdylib target
Allowing this was an unintended change in the 1.50 release, and may become an error in \
@ -230,7 +230,7 @@ fn link_arg_transitive_not_allowed() {
"build.rs",
r#"
fn main() {
println!("cargo:rustc-link-arg=--bogus");
println!("cargo::rustc-link-arg=--bogus");
}
"#,
)
@ -289,7 +289,7 @@ fn link_arg_with_doctest() {
"build.rs",
r#"
fn main() {
println!("cargo:rustc-link-arg=--this-is-a-bogus-flag");
println!("cargo::rustc-link-arg=--this-is-a-bogus-flag");
}
"#,
)
@ -313,7 +313,7 @@ fn build_script_extra_link_arg_tests() {
"build.rs",
r#"
fn main() {
println!("cargo:rustc-link-arg-tests=--this-is-a-bogus-flag");
println!("cargo::rustc-link-arg-tests=--this-is-a-bogus-flag");
}
"#,
)
@ -337,7 +337,7 @@ fn build_script_extra_link_arg_benches() {
"build.rs",
r#"
fn main() {
println!("cargo:rustc-link-arg-benches=--this-is-a-bogus-flag");
println!("cargo::rustc-link-arg-benches=--this-is-a-bogus-flag");
}
"#,
)
@ -361,7 +361,7 @@ fn build_script_extra_link_arg_examples() {
"build.rs",
r#"
fn main() {
println!("cargo:rustc-link-arg-examples=--this-is-a-bogus-flag");
println!("cargo::rustc-link-arg-examples=--this-is-a-bogus-flag");
}
"#,
)

View File

@ -343,7 +343,7 @@ fn build_script_feedback() {
.file("src/main.rs", "fn main() {}")
.file(
"build.rs",
r#"fn main() { println!("cargo:rustc-check-cfg=cfg(foo)"); }"#,
r#"fn main() { println!("cargo::rustc-check-cfg=cfg(foo)"); }"#,
)
.build();
@ -369,7 +369,7 @@ fn build_script_doc() {
.file("src/main.rs", "fn main() {}")
.file(
"build.rs",
r#"fn main() { println!("cargo:rustc-check-cfg=cfg(foo)"); }"#,
r#"fn main() { println!("cargo::rustc-check-cfg=cfg(foo)"); }"#,
)
.build();
@ -478,8 +478,8 @@ fn build_script_test() {
.file(
"build.rs",
r#"fn main() {
println!("cargo:rustc-check-cfg=cfg(foo)");
println!("cargo:rustc-cfg=foo");
println!("cargo::rustc-check-cfg=cfg(foo)");
println!("cargo::rustc-cfg=foo");
}"#,
)
.file(

View File

@ -721,7 +721,7 @@ fn build_script_needed_for_host_and_target() {
use std::env;
fn main() {
let target = env::var("TARGET").unwrap();
println!("cargo:rustc-flags=-L /path/to/{}", target);
println!("cargo::rustc-flags=-L /path/to/{}", target);
}
"#,
)
@ -1098,7 +1098,10 @@ fn platform_specific_variables_reflected_in_build_scripts() {
build = "build.rs"
"#,
)
.file("d1/build.rs", r#"fn main() { println!("cargo:val=1") }"#)
.file(
"d1/build.rs",
r#"fn main() { println!("cargo::metadata=val=1") }"#,
)
.file("d1/src/lib.rs", "")
.file(
"d2/Cargo.toml",
@ -1111,7 +1114,10 @@ fn platform_specific_variables_reflected_in_build_scripts() {
build = "build.rs"
"#,
)
.file("d2/build.rs", r#"fn main() { println!("cargo:val=1") }"#)
.file(
"d2/build.rs",
r#"fn main() { println!("cargo::metadata=val=1") }"#,
)
.file("d2/src/lib.rs", "")
.build();

View File

@ -570,7 +570,7 @@ fn non_local_build_script() {
"build.rs",
r#"
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo::rerun-if-changed=build.rs");
}
"#,
)

View File

@ -1021,7 +1021,7 @@ fn features() {
"bar/build.rs",
r#"
fn main() {
println!("cargo:rustc-cfg=bar");
println!("cargo::rustc-cfg=bar");
}
"#,
)

View File

@ -494,7 +494,7 @@ fn build_script_runtime_features() {
if is_set("CARGO_FEATURE_BUILD") {
res |= 4;
}
println!("cargo:rustc-cfg=RunCustomBuild=\"{}\"", res);
println!("cargo::rustc-cfg=RunCustomBuild=\"{}\"", res);
let mut res = 0;
if cfg!(feature = "normal") {
@ -506,7 +506,7 @@ fn build_script_runtime_features() {
if cfg!(feature = "build") {
res |= 4;
}
println!("cargo:rustc-cfg=CustomBuild=\"{}\"", res);
println!("cargo::rustc-cfg=CustomBuild=\"{}\"", res);
}
"#,
)
@ -562,7 +562,7 @@ fn build_script_runtime_features() {
r#"
fn main() {
assert_eq!(common::foo(), common::build_time());
println!("cargo:rustc-cfg=from_build=\"{}\"", common::foo());
println!("cargo::rustc-cfg=from_build=\"{}\"", common::foo());
}
"#,
)
@ -1792,8 +1792,8 @@ fn shared_dep_same_but_dependencies() {
"subdep/src/lib.rs",
r#"
pub fn feat_func() {
#[cfg(feature = "feat")] println!("cargo:warning=feat: enabled");
#[cfg(not(feature = "feat"))] println!("cargo:warning=feat: not enabled");
#[cfg(feature = "feat")] println!("cargo::warning=feat: enabled");
#[cfg(not(feature = "feat"))] println!("cargo::warning=feat: not enabled");
}
"#,
)
@ -1813,7 +1813,7 @@ warning: bin2@0.1.0: feat: enabled
)
.run();
p.process(p.bin("bin1"))
.with_stdout("cargo:warning=feat: not enabled")
.with_stdout("cargo::warning=feat: not enabled")
.run();
// Make sure everything stays cached.

View File

@ -658,7 +658,7 @@ fn rerun_if_changed_in_dep() {
"a/build.rs",
r#"
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo::rerun-if-changed=build.rs");
}
"#,
)
@ -1730,8 +1730,8 @@ fn dirty_both_lib_and_test() {
.success(),
"slib build failed"
);
println!("cargo:rustc-link-lib=slib");
println!("cargo:rustc-link-search={}", out_dir.display());
println!("cargo::rustc-link-lib=slib");
println!("cargo::rustc-link-search={}", out_dir.display());
}
"#,
)
@ -1772,7 +1772,7 @@ fn script_fails_stay_dirty() {
r#"
mod helper;
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo::rerun-if-changed=build.rs");
helper::doit();
}
"#,
@ -1810,7 +1810,7 @@ fn simulated_docker_deps_stay_cached() {
"build.rs",
r#"
fn main() {
println!("cargo:rerun-if-env-changed=SOMEVAR");
println!("cargo::rerun-if-env-changed=SOMEVAR");
}
"#,
)
@ -1821,7 +1821,7 @@ fn simulated_docker_deps_stay_cached() {
"build.rs",
r#"
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo::rerun-if-changed=build.rs");
}
"#,
)
@ -2107,7 +2107,7 @@ fn move_target_directory_with_path_deps() {
use std::path::Path;
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo::rerun-if-changed=build.rs");
let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("hello.rs");
fs::write(&dest_path, r#"
@ -2148,9 +2148,9 @@ fn rerun_if_changes() {
"build.rs",
r#"
fn main() {
println!("cargo:rerun-if-env-changed=FOO");
println!("cargo::rerun-if-env-changed=FOO");
if std::env::var("FOO").is_ok() {
println!("cargo:rerun-if-env-changed=BAR");
println!("cargo::rerun-if-env-changed=BAR");
}
}
"#,
@ -2648,7 +2648,7 @@ fn env_build_script_no_rebuild() {
"build.rs",
r#"
fn main() {
println!("cargo:rustc-env=FOO=bar");
println!("cargo::rustc-env=FOO=bar");
}
"#,
)

View File

@ -502,9 +502,9 @@ fn build_override_shared() {
r#"
fn main() {
if std::env::var("DEBUG").unwrap() != "false" {
println!("cargo:rustc-cfg=foo_debug");
println!("cargo::rustc-cfg=foo_debug");
} else {
println!("cargo:rustc-cfg=foo_release");
println!("cargo::rustc-cfg=foo_release");
}
}
"#,

View File

@ -1202,8 +1202,8 @@ fn run_with_library_paths() {
&format!(
r##"
fn main() {{
println!(r#"cargo:rustc-link-search=native={}"#);
println!(r#"cargo:rustc-link-search={}"#);
println!(r#"cargo::rustc-link-search=native={}"#);
println!(r#"cargo::rustc-link-search={}"#);
}}
"##,
dir1.display(),
@ -1261,9 +1261,9 @@ fn library_paths_sorted_alphabetically() {
&format!(
r##"
fn main() {{
println!(r#"cargo:rustc-link-search=native={}"#);
println!(r#"cargo:rustc-link-search=native={}"#);
println!(r#"cargo:rustc-link-search=native={}"#);
println!(r#"cargo::rustc-link-search=native={}"#);
println!(r#"cargo::rustc-link-search=native={}"#);
println!(r#"cargo::rustc-link-search=native={}"#);
}}
"##,
dir1.display(),
@ -1535,8 +1535,8 @@ fn run_link_system_path_macos() {
&format!(
r#"
fn main() {{
println!("cargo:rustc-link-lib=foo");
println!("cargo:rustc-link-search={}");
println!("cargo::rustc-link-lib=foo");
println!("cargo::rustc-link-search={}");
}}
"#,
p.target_debug_dir().display()

View File

@ -24,10 +24,10 @@ fn make_lib(lib_src: &str) {
r#"
fn main() {{
use std::io::Write;
println!("cargo:warning={{}}", "{}");
println!("cargo::warning={{}}", "{}");
println!("hidden stdout");
write!(&mut ::std::io::stderr(), "hidden stderr");
println!("cargo:warning={{}}", "{}");
println!("cargo::warning={{}}", "{}");
}}
"#,
WARNING1, WARNING2