Skip to content

Commit

Permalink
tests/run-make: fix unused_must_use issues and other test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
jieyouxu committed Jun 3, 2024
1 parent d720298 commit ecb1c8b
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 31 deletions.
3 changes: 1 addition & 2 deletions tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ fn main() {
let mut stable_path = PathBuf::from(env!("TMPDIR"));
stable_path.push("libstable.rmeta");

let output =
rustc().input("main.rs").emit("metadata").extern_("stable", &stable_path).command_output();
let output = rustc().input("main.rs").emit("metadata").extern_("stable", &stable_path).run();

let stderr = String::from_utf8_lossy(&output.stderr);
let version = include_str!(concat!(env!("S"), "/src/version"));
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/c-link-to-rust-staticlib/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ fn main() {
rustc().input("foo.rs").run();
cc().input("bar.c").input(static_lib("foo")).out_exe("bar").args(&extra_c_flags()).run();
run("bar");
fs::remove_file(static_lib("foo"));
fs::remove_file(static_lib("foo")).unwrap();
run("bar");
}
4 changes: 2 additions & 2 deletions tests/run-make/doctests-keep-binaries/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn setup_test_env<F: FnOnce(&Path, &Path)>(callback: F) {
create_dir(&out_dir).expect("failed to create doctests folder");
rustc().input("t.rs").crate_type("rlib").run();
callback(&out_dir, &tmp_dir().join("libt.rlib"));
remove_dir_all(out_dir);
remove_dir_all(out_dir).unwrap();
}

fn check_generated_binaries() {
Expand Down Expand Up @@ -60,6 +60,6 @@ fn main() {
.extern_("t", "libt.rlib")
.run();

remove_dir_all(run_dir_path);
remove_dir_all(run_dir_path).unwrap();
});
}
4 changes: 2 additions & 2 deletions tests/run-make/doctests-runtool/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ fn main() {
.current_dir(tmp_dir())
.run();

remove_dir_all(run_dir);
remove_dir_all(run_tool);
remove_dir_all(run_dir).unwrap();
remove_dir_all(run_tool).unwrap();
}
5 changes: 3 additions & 2 deletions tests/run-make/reset-codegen-1/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ fn main() {
("multi-output", Some("asm,obj")),
];
for (output_file, emit) in flags {
fs::remove_file(output_file).unwrap_or_default();
fs::remove_dir_all(tmp_dir()).unwrap_or_default();
fs::create_dir_all(tmp_dir()).unwrap();
compile(output_file, emit);
fs::remove_file(output_file);
fs::remove_dir_all(tmp_dir()).unwrap();
}
}
5 changes: 2 additions & 3 deletions tests/run-make/rustdoc-error-lines/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
use run_make_support::rustdoc;

fn main() {
let output =
String::from_utf8(rustdoc().input("input.rs").arg("--test").command_output().stdout)
.unwrap();
let output = rustdoc().input("input.rs").arg("--test").run_fail();
let output = String::from_utf8(output.stdout).unwrap();

let should_contain = &[
"input.rs - foo (line 5)",
Expand Down
19 changes: 8 additions & 11 deletions tests/run-make/rustdoc-scrape-examples-macros/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ fn main() {
let proc_crate_name = "foobar_macro";
let crate_name = "foobar";

let dylib_name = String::from_utf8(
rustc()
.crate_name(proc_crate_name)
.crate_type("dylib")
.arg("--print")
.arg("file-names")
.arg("-")
.command_output()
.stdout,
)
.unwrap();
let output = rustc()
.crate_name(proc_crate_name)
.crate_type("dylib")
.arg("--print")
.arg("file-names")
.arg("-")
.run();
let dylib_name = String::from_utf8(output.stdout).unwrap();

rustc()
.input("src/proc.rs")
Expand Down
4 changes: 2 additions & 2 deletions tests/run-make/rustdoc-shared-flags/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use run_make_support::{rustc, rustdoc, Diff};

fn compare_outputs(args: &[&str]) {
let rustc_output = String::from_utf8(rustc().args(args).command_output().stdout).unwrap();
let rustdoc_output = String::from_utf8(rustdoc().args(args).command_output().stdout).unwrap();
let rustc_output = String::from_utf8(rustc().args(args).run().stdout).unwrap();
let rustdoc_output = String::from_utf8(rustdoc().args(args).run().stdout).unwrap();

Diff::new().expected_text("rustc", rustc_output).actual_text("rustdoc", rustdoc_output).run();
}
Expand Down
12 changes: 6 additions & 6 deletions tests/run-make/same-lib-two-locations-no-panic/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@

//@ ignore-cross-compile

use run_make_support::{dynamic_lib, rust_lib, rustc, tmp_dir};
use run_make_support::{dynamic_lib, dynamic_lib_name, rust_lib, rust_lib_name, rustc, tmp_dir};
use std::fs;

fn main() {
let tmp_dir_other = tmp_dir().join("other");

fs::create_dir(&tmp_dir_other);
fs::create_dir(&tmp_dir_other).unwrap();
rustc().input("foo.rs").crate_type("dylib").arg("-Cprefer-dynamic").run();
fs::rename(dynamic_lib("foo"), &tmp_dir_other);
fs::rename(dynamic_lib("foo"), tmp_dir_other.join(dynamic_lib_name("foo"))).unwrap();
rustc().input("foo.rs").crate_type("dylib").arg("-Cprefer-dynamic").run();
rustc().input("bar.rs").library_search_path(&tmp_dir_other).run();
fs::remove_dir_all(tmp_dir());
fs::remove_dir_all(tmp_dir()).unwrap();

fs::create_dir_all(&tmp_dir_other);
fs::create_dir_all(&tmp_dir_other).unwrap();
rustc().input("foo.rs").crate_type("rlib").run();
fs::rename(rust_lib("foo"), &tmp_dir_other);
fs::rename(rust_lib("foo"), tmp_dir_other.join(rust_lib_name("foo"))).unwrap();
rustc().input("foo.rs").crate_type("rlib").run();
rustc().input("bar.rs").library_search_path(tmp_dir_other).run();
}

0 comments on commit ecb1c8b

Please sign in to comment.