Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests to fix nightly errors #15110

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions tests/testsuite/build_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,20 +878,26 @@ fn custom_build_script_rustc_flags() {
"foo/build.rs",
r#"
fn main() {
println!("cargo::rustc-flags=-l nonexistinglib -L /dummy/path1 -L /dummy/path2");
let root = std::env::current_dir().unwrap();
let root = root.parent().unwrap();
println!("cargo::rustc-flags=-l nonexistinglib \
-L {R}/dummy-path1 -L {R}/dummy-path2", R=root.display());
}
"#,
)
.build();
p.root().join("dummy-path1").mkdir_p();
p.root().join("dummy-path2").mkdir_p();

p.cargo("build --verbose").with_stderr_data(str![[r#"
p.cargo("build --verbose")
.with_stderr_data(str![[r#"
[LOCKING] 1 package to latest compatible version
[COMPILING] foo v0.5.0 ([ROOT]/foo/foo)
[RUNNING] `rustc --crate-name build_script_build --edition=2015 foo/build.rs [..]`
[RUNNING] `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build`
[RUNNING] `rustc --crate-name foo --edition=2015 foo/src/lib.rs [..]-L dependency=[ROOT]/foo/target/debug/deps -L /dummy/path1 -L /dummy/path2 -l nonexistinglib`
[RUNNING] `rustc --crate-name foo --edition=2015 foo/src/lib.rs [..]-L dependency=[ROOT]/foo/target/debug/deps -L [ROOT]/foo/dummy-path1 -L [ROOT]/foo/dummy-path2 -l nonexistinglib`
[COMPILING] bar v0.5.0 ([ROOT]/foo)
[RUNNING] `rustc --crate-name bar --edition=2015 src/main.rs [..]-L dependency=[ROOT]/foo/target/debug/deps --extern foo=[ROOT]/foo/target/debug/deps/libfoo-[HASH].rlib -L /dummy/path1 -L /dummy/path2`
[RUNNING] `rustc --crate-name bar --edition=2015 src/main.rs [..]-L dependency=[ROOT]/foo/target/debug/deps --extern foo=[ROOT]/foo/target/debug/deps/libfoo-[HASH].rlib -L [ROOT]/foo/dummy-path1 -L [ROOT]/foo/dummy-path2`
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

"#]]).run();
Expand Down Expand Up @@ -932,20 +938,25 @@ fn custom_build_script_rustc_flags_no_space() {
"foo/build.rs",
r#"
fn main() {
println!("cargo::rustc-flags=-lnonexistinglib -L/dummy/path1 -L/dummy/path2");
let root = std::env::current_dir().unwrap();
let root = root.parent().unwrap();
println!("cargo::rustc-flags=-lnonexistinglib \
-L {R}/dummy-path1 -L {R}/dummy-path2", R=root.display());
}
"#,
)
.build();
p.root().join("dummy-path1").mkdir_p();
p.root().join("dummy-path2").mkdir_p();

p.cargo("build --verbose").with_stderr_data(str![[r#"
[LOCKING] 1 package to latest compatible version
[COMPILING] foo v0.5.0 ([ROOT]/foo/foo)
[RUNNING] `rustc --crate-name build_script_build --edition=2015 foo/build.rs [..]`
[RUNNING] `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build`
[RUNNING] `rustc --crate-name foo --edition=2015 foo/src/lib.rs [..]-L dependency=[ROOT]/foo/target/debug/deps -L /dummy/path1 -L /dummy/path2 -l nonexistinglib`
[RUNNING] `rustc --crate-name foo --edition=2015 foo/src/lib.rs [..]-L dependency=[ROOT]/foo/target/debug/deps -L [ROOT]/foo/dummy-path1 -L [ROOT]/foo/dummy-path2 -l nonexistinglib`
[COMPILING] bar v0.5.0 ([ROOT]/foo)
[RUNNING] `rustc --crate-name bar --edition=2015 src/main.rs [..]-L dependency=[ROOT]/foo/target/debug/deps --extern foo=[ROOT]/foo/target/debug/deps/libfoo-[HASH].rlib -L /dummy/path1 -L /dummy/path2`
[RUNNING] `rustc --crate-name bar --edition=2015 src/main.rs [..]-L dependency=[ROOT]/foo/target/debug/deps --extern foo=[ROOT]/foo/target/debug/deps/libfoo-[HASH].rlib -L [ROOT]/foo/dummy-path1 -L [ROOT]/foo/dummy-path2`
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

"#]]).run();
Expand Down Expand Up @@ -2975,24 +2986,26 @@ fn flags_go_into_tests() {
"a/build.rs",
r#"
fn main() {
println!("cargo::rustc-link-search=test");
let path = std::env::current_dir().unwrap().parent().unwrap().join("link-dir");
println!("cargo::rustc-link-search={}", path.display());
}
"#,
)
.build();
p.root().join("link-dir").mkdir_p();

p.cargo("test -v --test=foo")
.with_stderr_data(str![[r#"
[LOCKING] 2 packages to latest compatible versions
[COMPILING] a v0.5.0 ([ROOT]/foo/a)
[RUNNING] `rustc [..] a/build.rs [..]`
[RUNNING] `[ROOT]/foo/target/debug/build/a-[HASH]/build-script-build`
[RUNNING] `rustc [..] a/src/lib.rs [..] -L test`
[RUNNING] `rustc [..] a/src/lib.rs [..] -L [ROOT]/foo/link-dir`
[COMPILING] b v0.5.0 ([ROOT]/foo/b)
[RUNNING] `rustc [..] b/src/lib.rs [..] -L test`
[RUNNING] `rustc [..] b/src/lib.rs [..] -L [ROOT]/foo/link-dir`
[COMPILING] foo v0.5.0 ([ROOT]/foo)
[RUNNING] `rustc [..] src/lib.rs [..] -L test`
[RUNNING] `rustc [..] tests/foo.rs [..] -L test`
[RUNNING] `rustc [..] src/lib.rs [..] -L [ROOT]/foo/link-dir`
[RUNNING] `rustc [..] tests/foo.rs [..] -L [ROOT]/foo/link-dir`
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[RUNNING] `[ROOT]/foo/target/debug/deps/foo-[HASH][EXE]`

Expand All @@ -3011,7 +3024,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini
.with_stderr_data(str![[r#"
[FRESH] a v0.5.0 ([ROOT]/foo/a)
[COMPILING] b v0.5.0 ([ROOT]/foo/b)
[RUNNING] `rustc --crate-name b [..] -L test`
[RUNNING] `rustc --crate-name b [..] -L [ROOT]/foo/link-dir`
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[RUNNING] `[ROOT]/foo/target/debug/deps/b-[HASH][EXE]`

Expand Down
12 changes: 8 additions & 4 deletions tests/testsuite/cross_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,9 @@ 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);
let root = std::env::current_dir().unwrap();
let root = root.parent().unwrap().join(format!("link-{target}"));
println!("cargo::rustc-flags=-L {}", root.display());
}
"#,
)
Expand All @@ -757,6 +759,8 @@ fn build_script_needed_for_host_and_target() {
",
)
.build();
p.root().join(format!("link-{target}")).mkdir_p();
p.root().join(format!("link-{}", rustc_host())).mkdir_p();

p.cargo("build -v --target")
.arg(&target)
Expand All @@ -769,11 +773,11 @@ fn build_script_needed_for_host_and_target() {
[RUNNING] `rustc [..] d1/src/lib.rs [..] --out-dir [ROOT]/foo/target/debug/deps [..]
[RUNNING] `rustc [..] d1/src/lib.rs [..] --out-dir [ROOT]/foo/target/[ALT_TARGET]/debug/deps [..]
[COMPILING] d2 v0.0.0 ([ROOT]/foo/d2)
[RUNNING] `rustc [..] d2/src/lib.rs [..] --out-dir [ROOT]/foo/target/debug/deps [..]
[RUNNING] `rustc [..] d2/src/lib.rs [..] --out-dir [ROOT]/foo/target/debug/deps [..]-L [ROOT]/foo/link-[HOST_TARGET]`
[COMPILING] foo v0.0.0 ([ROOT]/foo)
[RUNNING] `rustc [..] build.rs [..] --out-dir [ROOT]/foo/target/debug/build/foo-[HASH] [..]
[RUNNING] `rustc [..] build.rs [..] --out-dir [ROOT]/foo/target/debug/build/foo-[HASH] [..]-L [ROOT]/foo/link-[HOST_TARGET]`
[RUNNING] `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build`
[RUNNING] `rustc [..] src/main.rs [..] --out-dir [ROOT]/foo/target/[ALT_TARGET]/debug/deps --target [ALT_TARGET] [..]
[RUNNING] `rustc [..] src/main.rs [..] --out-dir [ROOT]/foo/target/[ALT_TARGET]/debug/deps --target [ALT_TARGET] [..]-L [ROOT]/foo/link-[ALT_TARGET]`
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s

"#]].unordered())
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/standard_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ fn no_implicit_alloc() {
.target_host()
.with_stderr_data(str![[r#"
...
error[E0433]: failed to resolve: use of undeclared crate or module `alloc`
error[E0433]: failed to resolve[..]`alloc`
...
"#]])
.with_status(101)
Expand Down
Loading