diff --git a/src/tools/run-make-support/src/fs.rs b/src/tools/run-make-support/src/fs.rs new file mode 100644 index 0000000000000..32e85c58eb68f --- /dev/null +++ b/src/tools/run-make-support/src/fs.rs @@ -0,0 +1,78 @@ +use std::fs; +use std::path::Path; + +/// A safe wrapper around `std::fs::remove_file` that prints the file path if an operation fails. +pub fn remove_file + std::fmt::Debug>(path: P) { + fs::remove_file(path.as_ref()).expect(&format!("The file in path \"{:?}\" could not be removed.", path)); +} + +/// A safe wrapper around `std::fs::copy` that prints the file paths if an operation fails. +pub fn copy + std::fmt::Debug, Q: AsRef + std::fmt::Debug>(from: P, to: Q) { + fs::copy(from.as_ref(), to.as_ref()).expect( + &format!("The file \"{:?}\" could not be copied over to \"{:?}\".", + from, + to, + )); +} + +/// A safe wrapper around `std::fs::File::create` that prints the file path if an operation fails. +pub fn create_file + std::fmt::Debug>(path: P) { + fs::File::create(path.as_ref()).expect(&format!("The file in path \"{:?}\" could not be created.", path)); +} + +/// A safe wrapper around `std::fs::read` that prints the file path if an operation fails. +pub fn read + std::fmt::Debug>(path: P) -> Vec { + fs::read(path.as_ref()).expect(&format!("The file in path \"{:?}\" could not be read.", path)) +} + +/// A safe wrapper around `std::fs::read_to_string` that prints the file path if an operation fails. +pub fn read_to_string + std::fmt::Debug>(path: P) -> String { + fs::read_to_string(path.as_ref()) + .expect(&format!("The file in path \"{:?}\" could not be read into a String.", path)) +} + +/// A safe wrapper around `std::fs::read_dir` that prints the file path if an operation fails. +pub fn read_dir + std::fmt::Debug>(path: P) -> fs::ReadDir { + fs::read_dir(path.as_ref()).expect(&format!("The directory in path \"{:?}\" could not be read.", path)) +} + +/// A safe wrapper around `std::fs::write` that prints the file path if an operation fails. +pub fn write + std::fmt::Debug, C: AsRef<[u8]>>(path: P, contents: C) { + fs::read(path.as_ref(), contents.as_ref()) + .expect(&format!("The file in path \"{:?}\" could not be written to.", path)); +} + +/// A safe wrapper around `std::fs::remove_dir_all` that prints the file path if an operation fails. +pub fn remove_dir_all + std::fmt::Debug>(path: P) { + fs::remove_dir_all(path.as_ref()).expect( + &format!("The directory in path \"{:?}\" could not be removed alongside all its contents.", + path, + )); +} + +/// A safe wrapper around `std::fs::create_dir` that prints the file path if an operation fails. +pub fn create_dir + std::fmt::Debug>(path: P) { + fs::create_dir(path.as_ref()) + .expect(&format!("The directory in path \"{:?}\" could not be created.", path)); +} + +/// A safe wrapper around `std::fs::create_dir_all` that prints the file path if an operation fails. +pub fn create_dir_all + std::fmt::Debug>(path: P) { + fs::create_dir_all(path.as_ref()) + .expect(&format!("The directory (and all its parents) in path \"{:?}\" could not be created.", path)); +} + +/// A safe wrapper around `std::fs::metadata` that prints the file path if an operation fails. +pub fn metadata + std::fmt::Debug>(path: P) -> fs::Metadata { + fs::metadata(path.as_ref()) + .expect(&format!("The file's metadata in path \"{:?}\" could not be read.", path)) +} + +/// A safe wrapper around `std::fs::rename` that prints the file paths if an operation fails. +pub fn rename + std::fmt::Debug, Q: AsRef + std::fmt::Debug>(from: P, to: Q) { + fs::rename(from.as_ref(), to.as_ref()).expect( + &format!("The file \"{:?}\" could not be moved over to \"{:?}\"."), + from, + to, + )); +} diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index c0ccc7085e45d..019a2187a9d3d 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -6,6 +6,7 @@ pub mod cc; pub mod clang; pub mod diff; +pub mod fs; pub mod llvm_readobj; pub mod run; pub mod rustc; diff --git a/tests/run-make/c-link-to-rust-staticlib/rmake.rs b/tests/run-make/c-link-to-rust-staticlib/rmake.rs index 63d5eb78c6987..76486eae99cbd 100644 --- a/tests/run-make/c-link-to-rust-staticlib/rmake.rs +++ b/tests/run-make/c-link-to-rust-staticlib/rmake.rs @@ -3,6 +3,7 @@ //@ ignore-cross-compile +use run_make_support::fs::remove_file; use run_make_support::{cc, extra_c_flags, run, rustc, static_lib}; use std::fs; @@ -10,6 +11,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")); + remove_file(static_lib("foo")); run("bar"); } diff --git a/tests/run-make/compiler-builtins/rmake.rs b/tests/run-make/compiler-builtins/rmake.rs index ea709da7303c6..f8596a85cf304 100644 --- a/tests/run-make/compiler-builtins/rmake.rs +++ b/tests/run-make/compiler-builtins/rmake.rs @@ -14,6 +14,7 @@ #![deny(warnings)] +use run_make_support::fs::{read, read_dir, write}; use run_make_support::object; use run_make_support::object::read::archive::ArchiveFile; use run_make_support::object::read::Object; @@ -41,8 +42,8 @@ fn main() { // Set up the tiniest Cargo project: An empty no_std library. Just enough to run -Zbuild-std. let manifest_path = tmp_path("Cargo.toml"); - std::fs::write(&manifest_path, MANIFEST.as_bytes()).unwrap(); - std::fs::write(tmp_path("lib.rs"), b"#![no_std]").unwrap(); + write(&manifest_path, MANIFEST.as_bytes()); + write(tmp_path("lib.rs"), b"#![no_std]"); let path = std::env::var("PATH").unwrap(); let rustc = std::env::var("RUSTC").unwrap(); @@ -71,8 +72,7 @@ fn main() { assert!(status.success()); let rlibs_path = target_dir.join(target).join("debug").join("deps"); - let compiler_builtins_rlib = std::fs::read_dir(rlibs_path) - .unwrap() + let compiler_builtins_rlib = read_dir(rlibs_path) .find_map(|e| { let path = e.unwrap().path(); let file_name = path.file_name().unwrap().to_str().unwrap(); @@ -86,7 +86,7 @@ fn main() { // rlib files are archives, where the archive members each a CGU, and we also have one called // lib.rmeta which is the encoded metadata. Each of the CGUs is an object file. - let data = std::fs::read(compiler_builtins_rlib).unwrap(); + let data = read(compiler_builtins_rlib); let mut defined_symbols = HashSet::new(); let mut undefined_relocations = HashSet::new(); diff --git a/tests/run-make/doctests-keep-binaries/rmake.rs b/tests/run-make/doctests-keep-binaries/rmake.rs index c632cf7bff3df..226965f6613a3 100644 --- a/tests/run-make/doctests-keep-binaries/rmake.rs +++ b/tests/run-make/doctests-keep-binaries/rmake.rs @@ -1,13 +1,13 @@ // Check that valid binaries are persisted by running them, regardless of whether the // --run or --no-run option is used. +use run_make_support::fs::{create_dir, remove_dir_all}; use run_make_support::{run, rustc, rustdoc, tmp_dir, tmp_path}; -use std::fs::{create_dir, remove_dir_all}; use std::path::Path; fn setup_test_env(callback: F) { let out_dir = tmp_path("doctests"); - create_dir(&out_dir).expect("failed to create doctests folder"); + create_dir(&out_dir); rustc().input("t.rs").crate_type("rlib").run(); callback(&out_dir, &tmp_path("libt.rlib")); remove_dir_all(out_dir); @@ -46,7 +46,7 @@ fn main() { setup_test_env(|_out_dir, extern_path| { let run_dir = "rundir"; let run_dir_path = tmp_path("rundir"); - create_dir(&run_dir_path).expect("failed to create rundir folder"); + create_dir(&run_dir_path); rustdoc() .current_dir(tmp_dir()) diff --git a/tests/run-make/doctests-runtool/rmake.rs b/tests/run-make/doctests-runtool/rmake.rs index e24ab4ca1d54d..e7f07dfafc38c 100644 --- a/tests/run-make/doctests-runtool/rmake.rs +++ b/tests/run-make/doctests-runtool/rmake.rs @@ -1,13 +1,13 @@ // Tests behavior of rustdoc `--runtool`. +use run_make_support::fs::{create_dir, remove_dir_all}; use run_make_support::{rustc, rustdoc, tmp_dir, tmp_path}; use std::env::current_dir; -use std::fs::{create_dir, remove_dir_all}; use std::path::PathBuf; fn mkdir(name: &str) -> PathBuf { let dir = tmp_path(name); - create_dir(&dir).expect("failed to create doctests folder"); + create_dir(&dir); dir } diff --git a/tests/run-make/issue-107495-archive-permissions/rmake.rs b/tests/run-make/issue-107495-archive-permissions/rmake.rs index 00d75f72a557b..7d2c498056edf 100644 --- a/tests/run-make/issue-107495-archive-permissions/rmake.rs +++ b/tests/run-make/issue-107495-archive-permissions/rmake.rs @@ -3,8 +3,8 @@ #[cfg(unix)] extern crate libc; +use run_make_support::fs; use run_make_support::{aux_build, tmp_path}; -use std::fs; #[cfg(unix)] use std::os::unix::fs::PermissionsExt; use std::path::Path; diff --git a/tests/run-make/no-intermediate-extras/rmake.rs b/tests/run-make/no-intermediate-extras/rmake.rs index 17160738b3797..054b766651ce9 100644 --- a/tests/run-make/no-intermediate-extras/rmake.rs +++ b/tests/run-make/no-intermediate-extras/rmake.rs @@ -11,6 +11,7 @@ use std::fs; fn main() { rustc().crate_type("rlib").arg("--test").input("foo.rs").run(); assert!( + // Do not use run-make-support's fs wrapper here - this needs to return an Error. fs::remove_file(tmp_path("foo.bc")).is_err(), "An unwanted .bc file was created by run-make/no-intermediate-extras." ); diff --git a/tests/run-make/non-unicode-env/rmake.rs b/tests/run-make/non-unicode-env/rmake.rs index a4843a52efd5b..56080af5575d1 100644 --- a/tests/run-make/non-unicode-env/rmake.rs +++ b/tests/run-make/non-unicode-env/rmake.rs @@ -1,3 +1,4 @@ +use run_make_support::fs; use run_make_support::rustc; fn main() { @@ -7,6 +8,6 @@ fn main() { let non_unicode: std::ffi::OsString = std::os::windows::ffi::OsStringExt::from_wide(&[0xD800]); let output = rustc().input("non_unicode_env.rs").env("NON_UNICODE_VAR", non_unicode).run_fail(); let actual = std::str::from_utf8(&output.stderr).unwrap(); - let expected = std::fs::read_to_string("non_unicode_env.stderr").unwrap(); + let expected = fs::read_to_string("non_unicode_env.stderr"); assert_eq!(actual, expected); } diff --git a/tests/run-make/non-unicode-in-incremental-dir/rmake.rs b/tests/run-make/non-unicode-in-incremental-dir/rmake.rs index 852744c835207..87bd8f4b3c3ac 100644 --- a/tests/run-make/non-unicode-in-incremental-dir/rmake.rs +++ b/tests/run-make/non-unicode-in-incremental-dir/rmake.rs @@ -5,6 +5,7 @@ fn main() { let non_unicode: &std::ffi::OsStr = std::os::unix::ffi::OsStrExt::from_bytes(&[0xFF]); #[cfg(windows)] let non_unicode: std::ffi::OsString = std::os::windows::ffi::OsStringExt::from_wide(&[0xD800]); + // Do not use run-make-support's fs wrapper, this needs special handling. match std::fs::create_dir(tmp_path(&non_unicode)) { // If an error occurs, check if creating a directory with a valid Unicode name would // succeed. @@ -17,8 +18,8 @@ fn main() { } let incr_dir = tmp_path("incr-dir"); rustc().input("foo.rs").incremental(&incr_dir).run(); - for crate_dir in std::fs::read_dir(&incr_dir).unwrap() { - std::fs::create_dir(crate_dir.unwrap().path().join(&non_unicode)).unwrap(); + for crate_dir in run_make_support::fs::read_dir(&incr_dir) { + run_make_support::fs::create_dir(crate_dir.unwrap().path().join(&non_unicode)); } rustc().input("foo.rs").incremental(&incr_dir).run(); } diff --git a/tests/run-make/print-cfg/rmake.rs b/tests/run-make/print-cfg/rmake.rs index 5f1ab5c86eaff..48c8c946edbaa 100644 --- a/tests/run-make/print-cfg/rmake.rs +++ b/tests/run-make/print-cfg/rmake.rs @@ -10,6 +10,7 @@ use std::ffi::OsString; use std::io::BufRead; use std::iter::FromIterator; +use run_make_support::fs; use run_make_support::{rustc, tmp_path}; struct PrintCfg { @@ -97,7 +98,7 @@ fn check(PrintCfg { target, includes, disallow }: PrintCfg) { let output = rustc().target(target).arg(print_arg).run(); - let output = std::fs::read_to_string(&tmp_path).unwrap(); + let output = fs::read_to_string(&tmp_path).unwrap(); check_(&output, includes, disallow); } diff --git a/tests/run-make/print-to-output/rmake.rs b/tests/run-make/print-to-output/rmake.rs index a42cb5c19ff17..3ac66f0049958 100644 --- a/tests/run-make/print-to-output/rmake.rs +++ b/tests/run-make/print-to-output/rmake.rs @@ -3,6 +3,7 @@ use std::ffi::OsString; +use run_make_support::fs; use run_make_support::{rustc, target, tmp_path}; struct Option<'a> { @@ -52,7 +53,7 @@ fn check(args: Option) { let _output = rustc().target(args.target).arg(print_arg).run(); - std::fs::read_to_string(&tmp_path).unwrap() + fs::read_to_string(&tmp_path) }; check_(&stdout, args.includes); diff --git a/tests/run-make/repr128-dwarf/rmake.rs b/tests/run-make/repr128-dwarf/rmake.rs index b425c89ba0085..efef46324acdb 100644 --- a/tests/run-make/repr128-dwarf/rmake.rs +++ b/tests/run-make/repr128-dwarf/rmake.rs @@ -3,6 +3,7 @@ use gimli::{AttributeValue, Dwarf, EndianRcSlice, Reader, RunTimeEndian}; use object::{Object, ObjectSection}; +use run_make_support::fs; use run_make_support::{gimli, object, rustc, tmp_path}; use std::borrow::Cow; use std::collections::HashMap; @@ -18,9 +19,7 @@ fn main() { .join("Resources") .join("DWARF") .join("repr128"); - let output = - std::fs::read(if dsym_location.try_exists().unwrap() { dsym_location } else { output }) - .unwrap(); + let output = fs::read(if dsym_location.try_exists().unwrap() { dsym_location } else { output }); let obj = object::File::parse(output.as_slice()).unwrap(); let endian = if obj.is_little_endian() { RunTimeEndian::Little } else { RunTimeEndian::Big }; let dwarf = gimli::Dwarf::load(|section| -> Result<_, ()> { diff --git a/tests/run-make/reset-codegen-1/rmake.rs b/tests/run-make/reset-codegen-1/rmake.rs index af2040ba62a45..3fdc704b5f7f5 100644 --- a/tests/run-make/reset-codegen-1/rmake.rs +++ b/tests/run-make/reset-codegen-1/rmake.rs @@ -7,8 +7,8 @@ //@ ignore-cross-compile +use run_make_support::fs; use run_make_support::{rustc, tmp_path}; -use std::fs; fn compile(output_file: &str, emit: Option<&str>) { let mut rustc = rustc(); @@ -31,7 +31,7 @@ fn main() { ("multi-output", Some("asm,obj")), ]; for (output_file, emit) in flags { - fs::remove_file(output_file).unwrap_or_default(); + std::fs::remove_file(output_file).unwrap_or_default(); compile(output_file, emit); fs::remove_file(output_file); } diff --git a/tests/run-make/rustdoc-test-args/rmake.rs b/tests/run-make/rustdoc-test-args/rmake.rs index e1b306b5627ed..7d20c4b6c4b29 100644 --- a/tests/run-make/rustdoc-test-args/rmake.rs +++ b/tests/run-make/rustdoc-test-args/rmake.rs @@ -1,10 +1,11 @@ +use run_make_support::fs; use run_make_support::{rustdoc, tmp_dir, tmp_path}; use std::path::Path; -use std::{fs, iter}; +use std::iter; fn generate_a_lot_of_cfgs(path: &Path) { let content = iter::repeat("--cfg=a\n").take(100_000).collect::(); - fs::write(path, content.as_bytes()).expect("failed to create args file"); + fs::write(path, content.as_bytes()); } fn main() { diff --git a/tests/run-make/rustdoc-themes/rmake.rs b/tests/run-make/rustdoc-themes/rmake.rs index 4cf29bf693a0a..95e76bf05c06f 100644 --- a/tests/run-make/rustdoc-themes/rmake.rs +++ b/tests/run-make/rustdoc-themes/rmake.rs @@ -1,5 +1,6 @@ // Test that rustdoc will properly load in a theme file and display it in the theme selector. +use run_make_support::fs; use run_make_support::{htmldocck, rustdoc, source_path, tmp_path}; fn main() { @@ -7,8 +8,7 @@ fn main() { let test_css = out_dir.join("test.css"); let no_script = - std::fs::read_to_string(source_path().join("src/librustdoc/html/static/css/noscript.css")) - .unwrap(); + fs::read_to_string(source_path().join("src/librustdoc/html/static/css/noscript.css")); let mut test_content = String::new(); let mut found_begin_light = false; @@ -23,8 +23,8 @@ fn main() { } } assert!(!test_content.is_empty()); - std::fs::create_dir_all(&out_dir).unwrap(); - std::fs::write(&test_css, test_content).unwrap(); + fs::create_dir_all(&out_dir); + fs::write(&test_css, test_content); rustdoc().output(&out_dir).input("foo.rs").arg("--theme").arg(&test_css).run(); assert!(htmldocck().arg(out_dir).arg("foo.rs").status().unwrap().success()); diff --git a/tests/run-make/rustdoc-verify-output-files/rmake.rs b/tests/run-make/rustdoc-verify-output-files/rmake.rs index 808c57570f5d0..42a34a618cd0a 100644 --- a/tests/run-make/rustdoc-verify-output-files/rmake.rs +++ b/tests/run-make/rustdoc-verify-output-files/rmake.rs @@ -1,4 +1,4 @@ -use std::fs::copy; +use run_make_support::fs::copy; use std::path::{Path, PathBuf}; use run_make_support::{copy_dir_all, recursive_diff, rustdoc, tmp_path}; @@ -38,7 +38,7 @@ fn main() { assert!(out_dir.join("foobar.json").is_file()); // Copy first json output to check if it's exactly same after second compilation. - copy(out_dir.join("foobar.json"), tmp_out_dir.join("foobar.json")).unwrap(); + copy(out_dir.join("foobar.json"), tmp_out_dir.join("foobar.json")); // Generate json doc on the same output. generate_docs(&out_dir, JsonOutput::Yes); diff --git a/tests/run-make/same-lib-two-locations-no-panic/rmake.rs b/tests/run-make/same-lib-two-locations-no-panic/rmake.rs index 080fbc39bc877..a69a87518d711 100644 --- a/tests/run-make/same-lib-two-locations-no-panic/rmake.rs +++ b/tests/run-make/same-lib-two-locations-no-panic/rmake.rs @@ -7,8 +7,8 @@ //@ ignore-cross-compile +use run_make_support::fs; use run_make_support::{dynamic_lib, rust_lib, rustc, tmp_dir, tmp_path}; -use std::fs; fn main() { let tmp_dir_other = tmp_path("other"); diff --git a/tests/run-make/wasm-custom-section/rmake.rs b/tests/run-make/wasm-custom-section/rmake.rs index 8a7a0cb6a5d26..330432665069e 100644 --- a/tests/run-make/wasm-custom-section/rmake.rs +++ b/tests/run-make/wasm-custom-section/rmake.rs @@ -7,7 +7,7 @@ fn main() { rustc().input("foo.rs").target("wasm32-wasip1").run(); rustc().input("bar.rs").target("wasm32-wasip1").arg("-Clto").opt().run(); - let file = std::fs::read(&tmp_path("bar.wasm")).unwrap(); + let file = run_make_support::fs::read(&tmp_path("bar.wasm")); let mut custom = HashMap::new(); for payload in wasmparser::Parser::new(0).parse_all(&file) { diff --git a/tests/run-make/wasm-custom-sections-opt/rmake.rs b/tests/run-make/wasm-custom-sections-opt/rmake.rs index 308c3c163ed58..9ba1cf38240ba 100644 --- a/tests/run-make/wasm-custom-sections-opt/rmake.rs +++ b/tests/run-make/wasm-custom-sections-opt/rmake.rs @@ -12,7 +12,7 @@ fn main() { fn verify(path: &Path) { eprintln!("verify {path:?}"); - let file = std::fs::read(&path).unwrap(); + let file = run_make_support::fs::read(&path); let mut custom = HashMap::new(); for payload in wasmparser::Parser::new(0).parse_all(&file) { diff --git a/tests/run-make/wasm-export-all-symbols/rmake.rs b/tests/run-make/wasm-export-all-symbols/rmake.rs index 2eef310d37a82..1955d920e2c7d 100644 --- a/tests/run-make/wasm-export-all-symbols/rmake.rs +++ b/tests/run-make/wasm-export-all-symbols/rmake.rs @@ -36,7 +36,7 @@ fn test(args: &[&str]) { fn verify_exports(path: &Path, exports: &[(&str, wasmparser::ExternalKind)]) { println!("verify {path:?}"); - let file = std::fs::read(path).unwrap(); + let file = run_make_support::fs::read(path); let mut wasm_exports = HashMap::new(); for payload in wasmparser::Parser::new(0).parse_all(&file) { let payload = payload.unwrap(); diff --git a/tests/run-make/wasm-import-module/rmake.rs b/tests/run-make/wasm-import-module/rmake.rs index 01d3fd9b0358b..bbbda16c09e9b 100644 --- a/tests/run-make/wasm-import-module/rmake.rs +++ b/tests/run-make/wasm-import-module/rmake.rs @@ -8,7 +8,7 @@ fn main() { rustc().input("foo.rs").target("wasm32-wasip1").run(); rustc().input("bar.rs").target("wasm32-wasip1").arg("-Clto").opt().run(); - let file = std::fs::read(&tmp_path("bar.wasm")).unwrap(); + let file = run_make_support::fs::read(&tmp_path("bar.wasm")); let mut imports = HashMap::new(); for payload in wasmparser::Parser::new(0).parse_all(&file) { diff --git a/tests/run-make/wasm-panic-small/rmake.rs b/tests/run-make/wasm-panic-small/rmake.rs index df92419379897..f3b154319e6f9 100644 --- a/tests/run-make/wasm-panic-small/rmake.rs +++ b/tests/run-make/wasm-panic-small/rmake.rs @@ -15,7 +15,7 @@ fn test(cfg: &str) { rustc().input("foo.rs").target("wasm32-wasip1").arg("-Clto").opt().cfg(cfg).run(); - let bytes = std::fs::read(&tmp_path("foo.wasm")).unwrap(); + let bytes = run_make_support::fs::read(&tmp_path("foo.wasm")); println!("{}", bytes.len()); assert!(bytes.len() < 40_000); } diff --git a/tests/run-make/wasm-spurious-import/rmake.rs b/tests/run-make/wasm-spurious-import/rmake.rs index 048daf5687bb5..002b2a52df455 100644 --- a/tests/run-make/wasm-spurious-import/rmake.rs +++ b/tests/run-make/wasm-spurious-import/rmake.rs @@ -13,7 +13,7 @@ fn main() { .arg("-Copt-level=z") .run(); - let file = std::fs::read(&tmp_path("main.wasm")).unwrap(); + let file = run_make_support::fs::read(&tmp_path("main.wasm")); let mut imports = HashMap::new(); for payload in wasmparser::Parser::new(0).parse_all(&file) { diff --git a/tests/run-make/wasm-stringify-ints-small/rmake.rs b/tests/run-make/wasm-stringify-ints-small/rmake.rs index 224b93bf90442..4fc830b3cfeb3 100644 --- a/tests/run-make/wasm-stringify-ints-small/rmake.rs +++ b/tests/run-make/wasm-stringify-ints-small/rmake.rs @@ -6,7 +6,7 @@ use run_make_support::{rustc, tmp_path}; fn main() { rustc().input("foo.rs").target("wasm32-wasip1").arg("-Clto").opt().run(); - let bytes = std::fs::read(&tmp_path("foo.wasm")).unwrap(); + let bytes = run_make_support::fs::read(&tmp_path("foo.wasm")); println!("{}", bytes.len()); assert!(bytes.len() < 50_000); } diff --git a/tests/run-make/wasm-symbols-different-module/rmake.rs b/tests/run-make/wasm-symbols-different-module/rmake.rs index 14849bd73a454..dba9e6548acf1 100644 --- a/tests/run-make/wasm-symbols-different-module/rmake.rs +++ b/tests/run-make/wasm-symbols-different-module/rmake.rs @@ -22,7 +22,7 @@ fn test(file: &str, args: &[&str], expected_imports: &[(&str, &[&str])]) { rustc().input(file).target("wasm32-wasip1").args(args).run(); - let file = std::fs::read(&tmp_path(file).with_extension("wasm")).unwrap(); + let file = run_make_support::fs::read(&tmp_path(file).with_extension("wasm")); let mut imports = HashMap::new(); for payload in wasmparser::Parser::new(0).parse_all(&file) { diff --git a/tests/run-make/wasm-symbols-not-exported/rmake.rs b/tests/run-make/wasm-symbols-not-exported/rmake.rs index 904bf90886496..f14d05be79aa6 100644 --- a/tests/run-make/wasm-symbols-not-exported/rmake.rs +++ b/tests/run-make/wasm-symbols-not-exported/rmake.rs @@ -17,7 +17,7 @@ fn main() { fn verify_symbols(path: &Path) { eprintln!("verify {path:?}"); - let file = std::fs::read(&path).unwrap(); + let file = run_make_support::fs::read(&path); for payload in wasmparser::Parser::new(0).parse_all(&file) { let payload = payload.unwrap(); diff --git a/tests/run-make/wasm-symbols-not-imported/rmake.rs b/tests/run-make/wasm-symbols-not-imported/rmake.rs index 45d94bf29c69a..384f091af47fb 100644 --- a/tests/run-make/wasm-symbols-not-imported/rmake.rs +++ b/tests/run-make/wasm-symbols-not-imported/rmake.rs @@ -16,7 +16,7 @@ fn main() { fn verify_symbols(path: &Path) { eprintln!("verify {path:?}"); - let file = std::fs::read(&path).unwrap(); + let file = run_make_support::fs::read(&path); for payload in wasmparser::Parser::new(0).parse_all(&file) { let payload = payload.unwrap();