make assert_stderr_contains print its contents on panic

This commit is contained in:
Oneirical 2024-06-09 16:43:24 -04:00
parent 03a4259c8b
commit b3c51323b5
5 changed files with 18 additions and 33 deletions

@ -1 +1 @@
Subproject commit 5228bfac8267ad24659a81b92ec5417976b5edbc
Subproject commit 45c1a6d69edfd1fc91fb7504cb73958dbd09441e

@ -1 +1 @@
Subproject commit 4dcbca118ab7f9ffac4728004c983754bc6a04ff
Subproject commit a1f47ec3f7cd076986f1bfcd7061f2e8cb1a726e

View File

@ -236,18 +236,6 @@ pub fn link_args(&mut self, link_args: &str) -> &mut Self {
self
}
/// Add an extra argument to prepend the linker invocation, via `-Zpre-link-arg`.
pub fn pre_link_arg(&mut self, link_arg: &str) -> &mut Self {
self.cmd.arg(format!("-Zpre-link-arg={link_arg}"));
self
}
/// Add multiple extra arguments to the linker invocation, via `-Zpre-link-args`.
pub fn pre_link_args(&mut self, link_args: &str) -> &mut Self {
self.cmd.arg(format!("-Zpre-link-args={link_args}"));
self
}
/// Specify a stdin input
pub fn stdin<I: AsRef<[u8]>>(&mut self, input: I) -> &mut Self {
self.cmd.set_stdin(input.as_ref().to_vec().into_boxed_slice());

View File

@ -3,6 +3,9 @@
// checks that linker arguments remain intact and in the order they were originally passed in.
// See https://github.com/rust-lang/rust/pull/70665
//@ ignore-msvc
// Reason: the ld linker does not exist on Windows.
use run_make_support::rustc;
fn main() {
@ -10,18 +13,18 @@ fn main() {
.input("empty.rs")
.linker_flavor("ld")
.link_arg("a")
.link_args("\"b c\"")
.link_args("\"d e\"")
.link_args("b c")
.link_args("d e")
.link_arg("f")
.run_fail()
.assert_stderr_contains("\"a\" \"b\" \"c\" \"d\" \"e\" \"f\"");
.assert_stderr_contains(r#""a" "b" "c" "d" "e" "f""#);
rustc()
.input("empty.rs")
.linker_flavor("ld")
.pre_link_arg("a")
.pre_link_args("\"b c\"")
.pre_link_args("\"d e\"")
.pre_link_arg("f")
.arg("-Zpre-link-arg=a")
.arg("-Zpre-link-args=b c")
.arg("-Zpre-link-args=d e")
.arg("-Zpre-link-arg=f")
.run_fail()
.assert_stderr_contains("\"a\" \"b\" \"c\" \"d\" \"e\" \"f\"");
.assert_stderr_contains(r#""a" "b" "c" "d" "e" "f""#);
}

View File

@ -8,18 +8,12 @@
//@ ignore-cross-compile
use run_make_support::fs_wrapper;
use run_make_support::{cwd, run, rustc};
use run_make_support::{run, rust_lib_name, rustc, test_while_readonly};
fn main() {
rustc().input("lib.rs").run();
let entries = fs_wrapper::read_dir(cwd());
for entry in entries {
if entry.path().extension().and_then(|s| s.to_str()) == Some("rlib") {
let mut perms = fs_wrapper::metadata(entry.path()).permissions();
perms.set_readonly(true);
fs_wrapper::set_permissions(entry.path(), perms);
}
}
rustc().input("main.rs").arg("-Clto").run();
run("main");
test_while_readonly(rust_lib_name("lib"), || {
rustc().input("main.rs").arg("-Clto").run();
run("main");
});
}