Skip to content

Commit

Permalink
make assert_stderr_contains print its contents on panic
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Jun 19, 2024
1 parent 03a4259 commit b3c5132
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/tools/cargo
Submodule cargo updated 74 files
+1 −1 .github/workflows/main.yml
+12 −12 Cargo.lock
+10 −10 Cargo.toml
+2 −2 crates/cargo-test-macro/Cargo.toml
+1 −1 crates/cargo-test-support/Cargo.toml
+54 −41 crates/cargo-test-support/src/compare.rs
+11 −6 crates/cargo-test-support/src/cross_compile.rs
+1 −1 crates/cargo-util-schemas/Cargo.toml
+2 −2 crates/cargo-util/Cargo.toml
+2 −2 crates/crates-io/Cargo.toml
+2 −2 credential/cargo-credential-libsecret/Cargo.toml
+2 −2 credential/cargo-credential-macos-keychain/Cargo.toml
+2 −2 credential/cargo-credential-wincred/Cargo.toml
+1 −1 src/bin/cargo/commands/update.rs
+1 −12 src/cargo/ops/cargo_compile/mod.rs
+75 −56 src/cargo/ops/cargo_package.rs
+1 −2 src/cargo/ops/registry/publish.rs
+17 −14 src/doc/contrib/src/issues.md
+1 −1 src/doc/man/cargo-bench.md
+1 −1 src/doc/man/cargo-metadata.md
+17 −0 src/doc/man/cargo-update.md
+1 −1 src/doc/man/cargo-vendor.md
+1 −1 src/doc/man/generated_txt/cargo-bench.txt
+1 −1 src/doc/man/generated_txt/cargo-metadata.txt
+21 −0 src/doc/man/generated_txt/cargo-update.txt
+1 −1 src/doc/man/generated_txt/cargo-vendor.txt
+1 −1 src/doc/src/commands/cargo-bench.md
+1 −1 src/doc/src/commands/cargo-metadata.md
+16 −0 src/doc/src/commands/cargo-update.md
+1 −1 src/doc/src/commands/cargo-vendor.md
+16 −11 src/doc/src/reference/unstable.md
+1 −1 src/etc/man/cargo-bench.1
+1 −1 src/etc/man/cargo-metadata.1
+30 −0 src/etc/man/cargo-update.1
+1 −1 src/etc/man/cargo-vendor.1
+3 −3 tests/testsuite/alt_registry.rs
+369 −302 tests/testsuite/artifact_dep.rs
+42 −16 tests/testsuite/artifact_dir.rs
+460 −465 tests/testsuite/bad_config.rs
+29 −21 tests/testsuite/bad_manifest_path.rs
+707 −277 tests/testsuite/bench.rs
+125 −68 tests/testsuite/build_script_env.rs
+1 −1 tests/testsuite/cargo_add/target/mod.rs
+1 −1 tests/testsuite/cargo_add/target/out/Cargo.toml
+2 −2 tests/testsuite/cargo_add/target/stderr.term.svg
+1 −1 tests/testsuite/cargo_features.rs
+3 −3 tests/testsuite/cargo_remove/invalid_target/out/Cargo.toml
+1 −1 tests/testsuite/cargo_remove/invalid_target/stderr.term.svg
+1 −1 tests/testsuite/cargo_remove/invalid_target_dep/mod.rs
+3 −3 tests/testsuite/cargo_remove/invalid_target_dep/out/Cargo.toml
+2 −2 tests/testsuite/cargo_remove/invalid_target_dep/stderr.term.svg
+3 −3 tests/testsuite/cargo_remove/remove-target.in/Cargo.toml
+1 −1 tests/testsuite/cargo_remove/target/mod.rs
+2 −2 tests/testsuite/cargo_remove/target/out/Cargo.toml
+1 −1 tests/testsuite/cargo_remove/target/stderr.term.svg
+1 −1 tests/testsuite/cargo_remove/target_build/mod.rs
+2 −2 tests/testsuite/cargo_remove/target_build/out/Cargo.toml
+1 −1 tests/testsuite/cargo_remove/target_build/stderr.term.svg
+1 −1 tests/testsuite/cargo_remove/target_dev/mod.rs
+2 −2 tests/testsuite/cargo_remove/target_dev/out/Cargo.toml
+1 −1 tests/testsuite/cargo_remove/target_dev/stderr.term.svg
+1 −1 tests/testsuite/cargo_update/help/stdout.term.svg
+2 −2 tests/testsuite/cross_publish.rs
+1 −1 tests/testsuite/features_namespaced.rs
+5 −5 tests/testsuite/inheritable_workspace_fields.rs
+42 −42 tests/testsuite/package.rs
+0 −27 tests/testsuite/profiles.rs
+13 −13 tests/testsuite/publish.rs
+6 −6 tests/testsuite/publish_lockfile.rs
+1 −1 tests/testsuite/registry.rs
+0 −2 tests/testsuite/run.rs
+13 −11 tests/testsuite/shell_quoting.rs
+1 −1 tests/testsuite/source_replacement.rs
+1 −1 tests/testsuite/weak_dep_features.rs
12 changes: 0 additions & 12 deletions src/tools/run-make-support/src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,6 @@ impl Rustc {
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());
Expand Down
19 changes: 11 additions & 8 deletions tests/run-make/link-args-order/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,28 @@
// 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() {
rustc()
.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""#);
}
16 changes: 5 additions & 11 deletions tests/run-make/lto-readonly-lib/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
}

0 comments on commit b3c5132

Please sign in to comment.