| author | bors <bors@rust-lang.org> 2024-06-11 15:50:25 UTC |
| committer | bors <bors@rust-lang.org> 2024-06-11 15:50:25 UTC |
| log | 3ea5e236ecb4c5f22437059f82d3915d311e4ec0 |
| tree | d53e401384bc689dfab71897283ef6c03638e8a1 |
| parent | 0c960618b56f662d933e8b864cd9632a99174e87 |
| parent | c84afee89851f0d0d5089d64d35225a6adb28453 |
run-make-support: add wrapper for `fs` operations
Suggested by #125728.
The point of this wrapper is to stop silent fails caused by forgetting to `unwrap` `fs` functions. However, functions like `fs::read` which return something and get stored in a variable should cause a failure on their own if they are not unwrapped (as the `Result` will be stored in the variable, and something will be done on that `Result` that should have been done to its contents). Is it still pertinent to wrap `fs::read_to_string`, `fs::metadata` and so on?
Closes: https://github.com/rust-lang/rust/issues/125728
try-job: x86_64-msvc
try-job: i686-mingw36 files changed, 211 insertions(+), 108 deletions(-)
src/tools/run-make-support/src/fs_wrapper.rs created+113| ... | ... | @@ -0,0 +1,113 @@ |
| 1 | use std::fs; | |
| 2 | use std::path::Path; | |
| 3 | ||
| 4 | /// A wrapper around [`std::fs::remove_file`] which includes the file path in the panic message.. | |
| 5 | #[track_caller] | |
| 6 | pub fn remove_file<P: AsRef<Path>>(path: P) { | |
| 7 | fs::remove_file(path.as_ref()) | |
| 8 | .expect(&format!("the file in path \"{}\" could not be removed", path.as_ref().display())); | |
| 9 | } | |
| 10 | ||
| 11 | /// A wrapper around [`std::fs::copy`] which includes the file path in the panic message. | |
| 12 | #[track_caller] | |
| 13 | pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) { | |
| 14 | fs::copy(from.as_ref(), to.as_ref()).expect(&format!( | |
| 15 | "the file \"{}\" could not be copied over to \"{}\"", | |
| 16 | from.as_ref().display(), | |
| 17 | to.as_ref().display(), | |
| 18 | )); | |
| 19 | } | |
| 20 | ||
| 21 | /// A wrapper around [`std::fs::File::create`] which includes the file path in the panic message.. | |
| 22 | #[track_caller] | |
| 23 | pub fn create_file<P: AsRef<Path>>(path: P) { | |
| 24 | fs::File::create(path.as_ref()) | |
| 25 | .expect(&format!("the file in path \"{}\" could not be created", path.as_ref().display())); | |
| 26 | } | |
| 27 | ||
| 28 | /// A wrapper around [`std::fs::read`] which includes the file path in the panic message.. | |
| 29 | #[track_caller] | |
| 30 | pub fn read<P: AsRef<Path>>(path: P) -> Vec<u8> { | |
| 31 | fs::read(path.as_ref()) | |
| 32 | .expect(&format!("the file in path \"{}\" could not be read", path.as_ref().display())) | |
| 33 | } | |
| 34 | ||
| 35 | /// A wrapper around [`std::fs::read_to_string`] which includes the file path in the panic message.. | |
| 36 | #[track_caller] | |
| 37 | pub fn read_to_string<P: AsRef<Path>>(path: P) -> String { | |
| 38 | fs::read_to_string(path.as_ref()).expect(&format!( | |
| 39 | "the file in path \"{}\" could not be read into a String", | |
| 40 | path.as_ref().display() | |
| 41 | )) | |
| 42 | } | |
| 43 | ||
| 44 | /// A wrapper around [`std::fs::read_dir`] which includes the file path in the panic message.. | |
| 45 | #[track_caller] | |
| 46 | pub fn read_dir<P: AsRef<Path>>(path: P) -> fs::ReadDir { | |
| 47 | fs::read_dir(path.as_ref()) | |
| 48 | .expect(&format!("the directory in path \"{}\" could not be read", path.as_ref().display())) | |
| 49 | } | |
| 50 | ||
| 51 | /// A wrapper around [`std::fs::write`] which includes the file path in the panic message.. | |
| 52 | #[track_caller] | |
| 53 | pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) { | |
| 54 | fs::write(path.as_ref(), contents.as_ref()).expect(&format!( | |
| 55 | "the file in path \"{}\" could not be written to", | |
| 56 | path.as_ref().display() | |
| 57 | )); | |
| 58 | } | |
| 59 | ||
| 60 | /// A wrapper around [`std::fs::remove_dir_all`] which includes the file path in the panic message.. | |
| 61 | #[track_caller] | |
| 62 | pub fn remove_dir_all<P: AsRef<Path>>(path: P) { | |
| 63 | fs::remove_dir_all(path.as_ref()).expect(&format!( | |
| 64 | "the directory in path \"{}\" could not be removed alongside all its contents", | |
| 65 | path.as_ref().display(), | |
| 66 | )); | |
| 67 | } | |
| 68 | ||
| 69 | /// A wrapper around [`std::fs::create_dir`] which includes the file path in the panic message.. | |
| 70 | #[track_caller] | |
| 71 | pub fn create_dir<P: AsRef<Path>>(path: P) { | |
| 72 | fs::create_dir(path.as_ref()).expect(&format!( | |
| 73 | "the directory in path \"{}\" could not be created", | |
| 74 | path.as_ref().display() | |
| 75 | )); | |
| 76 | } | |
| 77 | ||
| 78 | /// A wrapper around [`std::fs::create_dir_all`] which includes the file path in the panic message.. | |
| 79 | #[track_caller] | |
| 80 | pub fn create_dir_all<P: AsRef<Path>>(path: P) { | |
| 81 | fs::create_dir_all(path.as_ref()).expect(&format!( | |
| 82 | "the directory (and all its parents) in path \"{}\" could not be created", | |
| 83 | path.as_ref().display() | |
| 84 | )); | |
| 85 | } | |
| 86 | ||
| 87 | /// A wrapper around [`std::fs::metadata`] which includes the file path in the panic message.. | |
| 88 | #[track_caller] | |
| 89 | pub fn metadata<P: AsRef<Path>>(path: P) -> fs::Metadata { | |
| 90 | fs::metadata(path.as_ref()).expect(&format!( | |
| 91 | "the file's metadata in path \"{}\" could not be read", | |
| 92 | path.as_ref().display() | |
| 93 | )) | |
| 94 | } | |
| 95 | ||
| 96 | /// A wrapper around [`std::fs::rename`] which includes the file path in the panic message. | |
| 97 | #[track_caller] | |
| 98 | pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) { | |
| 99 | fs::rename(from.as_ref(), to.as_ref()).expect(&format!( | |
| 100 | "the file \"{}\" could not be moved over to \"{}\"", | |
| 101 | from.as_ref().display(), | |
| 102 | to.as_ref().display(), | |
| 103 | )); | |
| 104 | } | |
| 105 | ||
| 106 | /// A wrapper around [`std::fs::set_permissions`] which includes the file path in the panic message. | |
| 107 | #[track_caller] | |
| 108 | pub fn set_permissions<P: AsRef<Path>>(path: P, perm: fs::Permissions) { | |
| 109 | fs::set_permissions(path.as_ref(), perm).expect(&format!( | |
| 110 | "the file's permissions in path \"{}\" could not be changed", | |
| 111 | path.as_ref().display() | |
| 112 | )); | |
| 113 | } |
src/tools/run-make-support/src/lib.rs+8-14| ... | ... | @@ -8,6 +8,7 @@ pub mod clang; |
| 8 | 8 | mod command; |
| 9 | 9 | pub mod diff; |
| 10 | 10 | mod drop_bomb; |
| 11 | pub mod fs_wrapper; | |
| 11 | 12 | pub mod llvm_readobj; |
| 12 | 13 | pub mod run; |
| 13 | 14 | pub mod rustc; |
| ... | ... | @@ -153,7 +154,7 @@ pub fn dynamic_lib_extension() -> &'static str { |
| 153 | 154 | } |
| 154 | 155 | } |
| 155 | 156 | |
| 156 | /// Construct a rust library (rlib) name. | |
| 157 | /// Generate the name a rust library (rlib) would have. | |
| 157 | 158 | pub fn rust_lib_name(name: &str) -> String { |
| 158 | 159 | format!("lib{name}.rlib") |
| 159 | 160 | } |
| ... | ... | @@ -228,15 +229,15 @@ pub fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) { |
| 228 | 229 | fn copy_dir_all_inner(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> { |
| 229 | 230 | let dst = dst.as_ref(); |
| 230 | 231 | if !dst.is_dir() { |
| 231 | fs::create_dir_all(&dst)?; | |
| 232 | std::fs::create_dir_all(&dst)?; | |
| 232 | 233 | } |
| 233 | for entry in fs::read_dir(src)? { | |
| 234 | for entry in std::fs::read_dir(src)? { | |
| 234 | 235 | let entry = entry?; |
| 235 | 236 | let ty = entry.file_type()?; |
| 236 | 237 | if ty.is_dir() { |
| 237 | 238 | copy_dir_all_inner(entry.path(), dst.join(entry.file_name()))?; |
| 238 | 239 | } else { |
| 239 | fs::copy(entry.path(), dst.join(entry.file_name()))?; | |
| 240 | std::fs::copy(entry.path(), dst.join(entry.file_name()))?; | |
| 240 | 241 | } |
| 241 | 242 | } |
| 242 | 243 | Ok(()) |
| ... | ... | @@ -255,13 +256,6 @@ pub fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) { |
| 255 | 256 | |
| 256 | 257 | /// Check that all files in `dir1` exist and have the same content in `dir2`. Panic otherwise. |
| 257 | 258 | pub fn recursive_diff(dir1: impl AsRef<Path>, dir2: impl AsRef<Path>) { |
| 258 | fn read_file(path: &Path) -> Vec<u8> { | |
| 259 | match fs::read(path) { | |
| 260 | Ok(c) => c, | |
| 261 | Err(e) => panic!("Failed to read `{}`: {:?}", path.display(), e), | |
| 262 | } | |
| 263 | } | |
| 264 | ||
| 265 | 259 | let dir2 = dir2.as_ref(); |
| 266 | 260 | read_dir(dir1, |entry_path| { |
| 267 | 261 | let entry_name = entry_path.file_name().unwrap(); |
| ... | ... | @@ -269,8 +263,8 @@ pub fn recursive_diff(dir1: impl AsRef<Path>, dir2: impl AsRef<Path>) { |
| 269 | 263 | recursive_diff(&entry_path, &dir2.join(entry_name)); |
| 270 | 264 | } else { |
| 271 | 265 | let path2 = dir2.join(entry_name); |
| 272 | let file1 = read_file(&entry_path); | |
| 273 | let file2 = read_file(&path2); | |
| 266 | let file1 = fs_wrapper::read(&entry_path); | |
| 267 | let file2 = fs_wrapper::read(&path2); | |
| 274 | 268 | |
| 275 | 269 | // We don't use `assert_eq!` because they are `Vec<u8>`, so not great for display. |
| 276 | 270 | // Why not using String? Because there might be minified files or even potentially |
| ... | ... | @@ -286,7 +280,7 @@ pub fn recursive_diff(dir1: impl AsRef<Path>, dir2: impl AsRef<Path>) { |
| 286 | 280 | } |
| 287 | 281 | |
| 288 | 282 | pub fn read_dir<F: Fn(&Path)>(dir: impl AsRef<Path>, callback: F) { |
| 289 | for entry in fs::read_dir(dir).unwrap() { | |
| 283 | for entry in fs_wrapper::read_dir(dir) { | |
| 290 | 284 | callback(&entry.unwrap().path()); |
| 291 | 285 | } |
| 292 | 286 | } |
tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs+2-2| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | |
| 6 | 6 | use std::path::PathBuf; |
| 7 | 7 | |
| 8 | use run_make_support::{aux_build, rustc, source_root}; | |
| 8 | use run_make_support::{aux_build, fs_wrapper, rustc, source_root}; | |
| 9 | 9 | |
| 10 | 10 | fn main() { |
| 11 | 11 | aux_build().input("stable.rs").emit("metadata").run(); |
| ... | ... | @@ -13,7 +13,7 @@ fn main() { |
| 13 | 13 | let output = |
| 14 | 14 | rustc().input("main.rs").emit("metadata").extern_("stable", "libstable.rmeta").run(); |
| 15 | 15 | |
| 16 | let version = std::fs::read_to_string(source_root().join("src/version")).unwrap(); | |
| 16 | let version = fs_wrapper::read_to_string(source_root().join("src/version")); | |
| 17 | 17 | let expected_string = format!("stable since {}", version.trim()); |
| 18 | 18 | output.assert_stderr_contains(expected_string); |
| 19 | 19 | } |
tests/run-make/c-link-to-rust-dylib/rmake.rs+4-4| ... | ... | @@ -3,9 +3,9 @@ |
| 3 | 3 | |
| 4 | 4 | //@ ignore-cross-compile |
| 5 | 5 | |
| 6 | use std::fs::remove_file; | |
| 7 | ||
| 8 | use run_make_support::{cc, cwd, dynamic_lib_extension, is_msvc, read_dir, run, run_fail, rustc}; | |
| 6 | use run_make_support::{ | |
| 7 | cc, cwd, dynamic_lib_extension, fs_wrapper, is_msvc, read_dir, run, run_fail, rustc, | |
| 8 | }; | |
| 9 | 9 | |
| 10 | 10 | fn main() { |
| 11 | 11 | rustc().input("foo.rs").run(); |
| ... | ... | @@ -28,7 +28,7 @@ fn main() { |
| 28 | 28 | name.ends_with(".so") || name.ends_with(".dll") || name.ends_with(".dylib") |
| 29 | 29 | }) |
| 30 | 30 | { |
| 31 | remove_file(path).unwrap(); | |
| 31 | fs_wrapper::remove_file(path); | |
| 32 | 32 | } |
| 33 | 33 | }); |
| 34 | 34 | run_fail("bar"); |
tests/run-make/c-link-to-rust-staticlib/rmake.rs+2-1| ... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | |
| 4 | 4 | //@ ignore-cross-compile |
| 5 | 5 | |
| 6 | use run_make_support::fs_wrapper::remove_file; | |
| 6 | 7 | use run_make_support::{cc, extra_c_flags, run, rustc, static_lib_name}; |
| 7 | 8 | use std::fs; |
| 8 | 9 | |
| ... | ... | @@ -10,6 +11,6 @@ fn main() { |
| 10 | 11 | rustc().input("foo.rs").run(); |
| 11 | 12 | cc().input("bar.c").input(static_lib_name("foo")).out_exe("bar").args(&extra_c_flags()).run(); |
| 12 | 13 | run("bar"); |
| 13 | fs::remove_file(static_lib_name("foo")); | |
| 14 | remove_file(static_lib_name("foo")); | |
| 14 | 15 | run("bar"); |
| 15 | 16 | } |
tests/run-make/cdylib/rmake.rs+2-4| ... | ... | @@ -10,9 +10,7 @@ |
| 10 | 10 | |
| 11 | 11 | //@ ignore-cross-compile |
| 12 | 12 | |
| 13 | use std::fs::remove_file; | |
| 14 | ||
| 15 | use run_make_support::{cc, cwd, dynamic_lib_name, is_msvc, run, rustc}; | |
| 13 | use run_make_support::{cc, cwd, dynamic_lib_name, fs_wrapper, is_msvc, run, rustc}; | |
| 16 | 14 | |
| 17 | 15 | fn main() { |
| 18 | 16 | rustc().input("bar.rs").run(); |
| ... | ... | @@ -25,7 +23,7 @@ fn main() { |
| 25 | 23 | } |
| 26 | 24 | |
| 27 | 25 | run("foo"); |
| 28 | remove_file(dynamic_lib_name("foo")).unwrap(); | |
| 26 | fs_wrapper::remove_file(dynamic_lib_name("foo")); | |
| 29 | 27 | |
| 30 | 28 | rustc().input("foo.rs").arg("-Clto").run(); |
| 31 | 29 | run("foo"); |
tests/run-make/compiler-builtins/rmake.rs+3-3| ... | ... | @@ -14,6 +14,7 @@ |
| 14 | 14 | |
| 15 | 15 | #![deny(warnings)] |
| 16 | 16 | |
| 17 | use run_make_support::fs_wrapper::{read, read_dir}; | |
| 17 | 18 | use run_make_support::object::read::archive::ArchiveFile; |
| 18 | 19 | use run_make_support::object::read::Object; |
| 19 | 20 | use run_make_support::object::ObjectSection; |
| ... | ... | @@ -55,8 +56,7 @@ fn main() { |
| 55 | 56 | cmd.run(); |
| 56 | 57 | |
| 57 | 58 | let rlibs_path = target_dir.join(target).join("debug").join("deps"); |
| 58 | let compiler_builtins_rlib = std::fs::read_dir(rlibs_path) | |
| 59 | .unwrap() | |
| 59 | let compiler_builtins_rlib = read_dir(rlibs_path) | |
| 60 | 60 | .find_map(|e| { |
| 61 | 61 | let path = e.unwrap().path(); |
| 62 | 62 | let file_name = path.file_name().unwrap().to_str().unwrap(); |
| ... | ... | @@ -70,7 +70,7 @@ fn main() { |
| 70 | 70 | |
| 71 | 71 | // rlib files are archives, where the archive members each a CGU, and we also have one called |
| 72 | 72 | // lib.rmeta which is the encoded metadata. Each of the CGUs is an object file. |
| 73 | let data = std::fs::read(compiler_builtins_rlib).unwrap(); | |
| 73 | let data = read(compiler_builtins_rlib); | |
| 74 | 74 | |
| 75 | 75 | let mut defined_symbols = HashSet::new(); |
| 76 | 76 | let mut undefined_relocations = HashSet::new(); |
tests/run-make/const-prop-lint/rmake.rs+2-4| ... | ... | @@ -1,13 +1,11 @@ |
| 1 | 1 | // Tests that const prop lints interrupting codegen don't leave `.o` files around. |
| 2 | 2 | |
| 3 | use std::fs; | |
| 4 | ||
| 5 | use run_make_support::{cwd, rustc}; | |
| 3 | use run_make_support::{cwd, fs_wrapper, rustc}; | |
| 6 | 4 | |
| 7 | 5 | fn main() { |
| 8 | 6 | rustc().input("input.rs").run_fail().assert_exit_code(1); |
| 9 | 7 | |
| 10 | for entry in fs::read_dir(cwd()).unwrap() { | |
| 8 | for entry in fs_wrapper::read_dir(cwd()) { | |
| 11 | 9 | let entry = entry.unwrap(); |
| 12 | 10 | let path = entry.path(); |
| 13 | 11 |
tests/run-make/doctests-keep-binaries/rmake.rs+4-4| ... | ... | @@ -1,13 +1,13 @@ |
| 1 | 1 | // Check that valid binaries are persisted by running them, regardless of whether the |
| 2 | 2 | // --run or --no-run option is used. |
| 3 | 3 | |
| 4 | use run_make_support::fs_wrapper::{create_dir, remove_dir_all}; | |
| 4 | 5 | use run_make_support::{run, rustc, rustdoc}; |
| 5 | use std::fs::{create_dir, remove_dir_all}; | |
| 6 | 6 | use std::path::Path; |
| 7 | 7 | |
| 8 | 8 | fn setup_test_env<F: FnOnce(&Path, &Path)>(callback: F) { |
| 9 | 9 | let out_dir = Path::new("doctests"); |
| 10 | create_dir(&out_dir).expect("failed to create doctests folder"); | |
| 10 | create_dir(&out_dir); | |
| 11 | 11 | rustc().input("t.rs").crate_type("rlib").run(); |
| 12 | 12 | callback(&out_dir, Path::new("libt.rlib")); |
| 13 | 13 | remove_dir_all(out_dir); |
| ... | ... | @@ -43,9 +43,9 @@ fn main() { |
| 43 | 43 | check_generated_binaries(); |
| 44 | 44 | }); |
| 45 | 45 | // Behavior with --test-run-directory with relative paths. |
| 46 | setup_test_env(|_out_dir, extern_path| { | |
| 46 | setup_test_env(|_out_dir, _extern_path| { | |
| 47 | 47 | let run_dir_path = Path::new("rundir"); |
| 48 | create_dir(&run_dir_path).expect("failed to create rundir folder"); | |
| 48 | create_dir(&run_dir_path); | |
| 49 | 49 | |
| 50 | 50 | rustdoc() |
| 51 | 51 | .input("t.rs") |
tests/run-make/doctests-runtool/rmake.rs+2-2| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | 1 | // Tests behavior of rustdoc `--runtool`. |
| 2 | 2 | |
| 3 | use run_make_support::fs_wrapper::{create_dir, remove_dir_all}; | |
| 3 | 4 | use run_make_support::{rustc, rustdoc}; |
| 4 | use std::fs::{create_dir, remove_dir_all}; | |
| 5 | 5 | use std::path::PathBuf; |
| 6 | 6 | |
| 7 | 7 | fn mkdir(name: &str) -> PathBuf { |
| 8 | 8 | let dir = PathBuf::from(name); |
| 9 | create_dir(&dir).expect("failed to create doctests folder"); | |
| 9 | create_dir(&dir); | |
| 10 | 10 | dir |
| 11 | 11 | } |
| 12 | 12 |
tests/run-make/emit-named-files/rmake.rs+2-3| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | use std::fs::create_dir; | |
| 2 | 1 | use std::path::Path; |
| 3 | 2 | |
| 4 | use run_make_support::rustc; | |
| 3 | use run_make_support::{fs_wrapper, rustc}; | |
| 5 | 4 | |
| 6 | 5 | fn emit_and_check(out_dir: &Path, out_file: &str, format: &str) { |
| 7 | 6 | let out_file = out_dir.join(out_file); |
| ... | ... | @@ -12,7 +11,7 @@ fn emit_and_check(out_dir: &Path, out_file: &str, format: &str) { |
| 12 | 11 | fn main() { |
| 13 | 12 | let out_dir = Path::new("emit"); |
| 14 | 13 | |
| 15 | create_dir(&out_dir).unwrap(); | |
| 14 | fs_wrapper::create_dir(&out_dir); | |
| 16 | 15 | |
| 17 | 16 | emit_and_check(&out_dir, "libfoo.s", "asm"); |
| 18 | 17 | emit_and_check(&out_dir, "libfoo.bc", "llvm-bc"); |
tests/run-make/incr-prev-body-beyond-eof/rmake.rs+5-6| ... | ... | @@ -13,15 +13,14 @@ |
| 13 | 13 | //@ ignore-nvptx64-nvidia-cuda |
| 14 | 14 | // FIXME: can't find crate for `std` |
| 15 | 15 | |
| 16 | use run_make_support::fs_wrapper as fs; | |
| 16 | 17 | use run_make_support::rustc; |
| 17 | use std::fs; | |
| 18 | 18 | |
| 19 | 19 | fn main() { |
| 20 | // FIXME(Oneirical): Use run_make_support::fs_wrapper here. | |
| 21 | fs::create_dir("src").unwrap(); | |
| 22 | fs::create_dir("incr").unwrap(); | |
| 23 | fs::copy("a.rs", "src/main.rs").unwrap(); | |
| 20 | fs::create_dir("src"); | |
| 21 | fs::create_dir("incr"); | |
| 22 | fs::copy("a.rs", "src/main.rs"); | |
| 24 | 23 | rustc().incremental("incr").input("src/main.rs").run(); |
| 25 | fs::copy("b.rs", "src/main.rs").unwrap(); | |
| 24 | fs::copy("b.rs", "src/main.rs"); | |
| 26 | 25 | rustc().incremental("incr").input("src/main.rs").run(); |
| 27 | 26 | } |
tests/run-make/issue-107495-archive-permissions/rmake.rs+3-3| ... | ... | @@ -3,8 +3,8 @@ |
| 3 | 3 | #[cfg(unix)] |
| 4 | 4 | extern crate libc; |
| 5 | 5 | |
| 6 | use run_make_support::aux_build; | |
| 7 | use std::fs; | |
| 6 | use run_make_support::{aux_build, fs_wrapper}; | |
| 7 | ||
| 8 | 8 | #[cfg(unix)] |
| 9 | 9 | use std::os::unix::fs::PermissionsExt; |
| 10 | 10 | use std::path::Path; |
| ... | ... | @@ -20,7 +20,7 @@ fn main() { |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | fn verify(path: &Path) { |
| 23 | let perm = fs::metadata(path).unwrap().permissions(); | |
| 23 | let perm = fs_wrapper::metadata(path).permissions(); | |
| 24 | 24 | |
| 25 | 25 | assert!(!perm.readonly()); |
| 26 | 26 |
tests/run-make/mixing-formats/rmake.rs-1| ... | ... | @@ -13,7 +13,6 @@ |
| 13 | 13 | //@ ignore-cross-compile |
| 14 | 14 | |
| 15 | 15 | use run_make_support::{run_in_tmpdir, rustc}; |
| 16 | use std::fs; | |
| 17 | 16 | |
| 18 | 17 | fn main() { |
| 19 | 18 | run_in_tmpdir(|| { |
tests/run-make/non-unicode-env/rmake.rs+2-1| ... | ... | @@ -1,3 +1,4 @@ |
| 1 | use run_make_support::fs_wrapper; | |
| 1 | 2 | use run_make_support::rustc; |
| 2 | 3 | |
| 3 | 4 | fn main() { |
| ... | ... | @@ -6,6 +7,6 @@ fn main() { |
| 6 | 7 | #[cfg(windows)] |
| 7 | 8 | let non_unicode: std::ffi::OsString = std::os::windows::ffi::OsStringExt::from_wide(&[0xD800]); |
| 8 | 9 | let output = rustc().input("non_unicode_env.rs").env("NON_UNICODE_VAR", non_unicode).run_fail(); |
| 9 | let expected = std::fs::read_to_string("non_unicode_env.stderr").unwrap(); | |
| 10 | let expected = fs_wrapper::read_to_string("non_unicode_env.stderr"); | |
| 10 | 11 | output.assert_stderr_equals(expected); |
| 11 | 12 | } |
tests/run-make/non-unicode-in-incremental-dir/rmake.rs+3-3| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | use run_make_support::rustc; | |
| 1 | use run_make_support::{fs_wrapper, rustc}; | |
| 2 | 2 | |
| 3 | 3 | fn main() { |
| 4 | 4 | #[cfg(unix)] |
| ... | ... | @@ -17,8 +17,8 @@ fn main() { |
| 17 | 17 | } |
| 18 | 18 | let incr_dir = "incr-dir"; |
| 19 | 19 | rustc().input("foo.rs").incremental(&incr_dir).run(); |
| 20 | for crate_dir in std::fs::read_dir(&incr_dir).unwrap() { | |
| 21 | std::fs::create_dir(crate_dir.unwrap().path().join(&non_unicode)).unwrap(); | |
| 20 | for crate_dir in fs_wrapper::read_dir(&incr_dir) { | |
| 21 | fs_wrapper::create_dir(crate_dir.unwrap().path().join(&non_unicode)); | |
| 22 | 22 | } |
| 23 | 23 | rustc().input("foo.rs").incremental(&incr_dir).run(); |
| 24 | 24 | } |
tests/run-make/print-cfg/rmake.rs+2-2| ... | ... | @@ -10,7 +10,7 @@ use std::ffi::OsString; |
| 10 | 10 | use std::iter::FromIterator; |
| 11 | 11 | use std::path::PathBuf; |
| 12 | 12 | |
| 13 | use run_make_support::rustc; | |
| 13 | use run_make_support::{fs_wrapper, rustc}; | |
| 14 | 14 | |
| 15 | 15 | struct PrintCfg { |
| 16 | 16 | target: &'static str, |
| ... | ... | @@ -96,7 +96,7 @@ fn check(PrintCfg { target, includes, disallow }: PrintCfg) { |
| 96 | 96 | |
| 97 | 97 | rustc().target(target).arg(print_arg).run(); |
| 98 | 98 | |
| 99 | let output = std::fs::read_to_string(&tmp_path).unwrap(); | |
| 99 | let output = fs_wrapper::read_to_string(&tmp_path); | |
| 100 | 100 | |
| 101 | 101 | check_(&output, includes, disallow); |
| 102 | 102 | } |
tests/run-make/print-to-output/rmake.rs+2-2| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | use std::ffi::OsString; |
| 5 | 5 | use std::path::PathBuf; |
| 6 | 6 | |
| 7 | use run_make_support::{rustc, target}; | |
| 7 | use run_make_support::{fs_wrapper, rustc, target}; | |
| 8 | 8 | |
| 9 | 9 | struct Option<'a> { |
| 10 | 10 | target: &'a str, |
| ... | ... | @@ -49,7 +49,7 @@ fn check(args: Option) { |
| 49 | 49 | |
| 50 | 50 | rustc().target(args.target).arg(print_arg).run(); |
| 51 | 51 | |
| 52 | std::fs::read_to_string(&tmp_path).unwrap() | |
| 52 | fs_wrapper::read_to_string(&tmp_path) | |
| 53 | 53 | }; |
| 54 | 54 | |
| 55 | 55 | check_(&stdout, args.includes); |
tests/run-make/repr128-dwarf/rmake.rs+2-3| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | |
| 4 | 4 | use gimli::{AttributeValue, EndianRcSlice, Reader, RunTimeEndian}; |
| 5 | 5 | use object::{Object, ObjectSection}; |
| 6 | use run_make_support::{gimli, object, rustc}; | |
| 6 | use run_make_support::{fs_wrapper, gimli, object, rustc}; | |
| 7 | 7 | use std::collections::HashMap; |
| 8 | 8 | use std::path::PathBuf; |
| 9 | 9 | use std::rc::Rc; |
| ... | ... | @@ -19,8 +19,7 @@ fn main() { |
| 19 | 19 | .join("DWARF") |
| 20 | 20 | .join("repr128"); |
| 21 | 21 | let output = |
| 22 | std::fs::read(if dsym_location.try_exists().unwrap() { dsym_location } else { output }) | |
| 23 | .unwrap(); | |
| 22 | fs_wrapper::read(if dsym_location.try_exists().unwrap() { dsym_location } else { output }); | |
| 24 | 23 | let obj = object::File::parse(output.as_slice()).unwrap(); |
| 25 | 24 | let endian = if obj.is_little_endian() { RunTimeEndian::Little } else { RunTimeEndian::Big }; |
| 26 | 25 | let dwarf = gimli::Dwarf::load(|section| -> Result<_, ()> { |
tests/run-make/reset-codegen-1/rmake.rs+9-5| ... | ... | @@ -7,8 +7,8 @@ |
| 7 | 7 | |
| 8 | 8 | //@ ignore-cross-compile |
| 9 | 9 | |
| 10 | use run_make_support::rustc; | |
| 11 | use std::fs; | |
| 10 | use run_make_support::{bin_name, fs_wrapper, rustc}; | |
| 11 | use std::path::Path; | |
| 12 | 12 | |
| 13 | 13 | fn compile(output_file: &str, emit: Option<&str>) { |
| 14 | 14 | let mut rustc = rustc(); |
| ... | ... | @@ -28,11 +28,15 @@ fn main() { |
| 28 | 28 | ("link-output", Some("link")), |
| 29 | 29 | ("obj-output", Some("obj")), |
| 30 | 30 | ("dep-output", Some("dep-info")), |
| 31 | ("multi-output", Some("asm,obj")), | |
| 32 | 31 | ]; |
| 33 | 32 | for (output_file, emit) in flags { |
| 34 | fs::remove_file(output_file).unwrap_or_default(); | |
| 33 | // In the None case, bin_name is required for successful Windows compilation. | |
| 34 | let output_file = &bin_name(output_file); | |
| 35 | 35 | compile(output_file, emit); |
| 36 | fs::remove_file(output_file); | |
| 36 | assert!(Path::new(output_file).is_file()); | |
| 37 | 37 | } |
| 38 | ||
| 39 | compile("multi-output", Some("asm,obj")); | |
| 40 | assert!(Path::new("multi-output.s").is_file()); | |
| 41 | assert!(Path::new("multi-output.o").is_file()); | |
| 38 | 42 | } |
tests/run-make/resolve-rename/rmake.rs+3-2| ... | ... | @@ -5,11 +5,12 @@ |
| 5 | 5 | // the renamed library. |
| 6 | 6 | // See https://github.com/rust-lang/rust/pull/49253 |
| 7 | 7 | |
| 8 | use run_make_support::fs_wrapper; | |
| 8 | 9 | use run_make_support::rustc; |
| 9 | use std::fs; | |
| 10 | ||
| 10 | 11 | fn main() { |
| 11 | 12 | rustc().extra_filename("-hash").input("foo.rs").run(); |
| 12 | 13 | rustc().input("bar.rs").run(); |
| 13 | fs::rename("libfoo-hash.rlib", "libfoo-another-hash.rlib").unwrap(); | |
| 14 | fs_wrapper::rename("libfoo-hash.rlib", "libfoo-another-hash.rlib"); | |
| 14 | 15 | rustc().input("baz.rs").run(); |
| 15 | 16 | } |
tests/run-make/rustdoc-scrape-examples-remap/scrape.rs+2-4| ... | ... | @@ -1,12 +1,10 @@ |
| 1 | use run_make_support::{htmldocck, rustc, rustdoc, source_root}; | |
| 2 | use std::fs::read_dir; | |
| 1 | use run_make_support::{fs_wrapper, htmldocck, rustc, rustdoc, source_root}; | |
| 3 | 2 | use std::path::Path; |
| 4 | 3 | |
| 5 | 4 | pub fn scrape(extra_args: &[&str]) { |
| 6 | 5 | let out_dir = Path::new("rustdoc"); |
| 7 | 6 | let crate_name = "foobar"; |
| 8 | let deps = read_dir("examples") | |
| 9 | .unwrap() | |
| 7 | let deps = fs_wrapper::read_dir("examples") | |
| 10 | 8 | .filter_map(|entry| entry.ok().map(|e| e.path())) |
| 11 | 9 | .filter(|path| path.is_file() && path.extension().is_some_and(|ext| ext == "rs")) |
| 12 | 10 | .collect::<Vec<_>>(); |
tests/run-make/rustdoc-test-args/rmake.rs+3-3| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use run_make_support::rustdoc; | |
| 1 | use run_make_support::{fs_wrapper, rustdoc}; | |
| 2 | use std::iter; | |
| 2 | 3 | use std::path::Path; |
| 3 | use std::{fs, iter}; | |
| 4 | 4 | |
| 5 | 5 | fn generate_a_lot_of_cfgs(path: &Path) { |
| 6 | 6 | let content = iter::repeat("--cfg=a\n").take(100_000).collect::<String>(); |
| 7 | fs::write(path, content.as_bytes()).expect("failed to create args file"); | |
| 7 | fs_wrapper::write(path, content.as_bytes()); | |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | fn main() { |
tests/run-make/rustdoc-themes/rmake.rs+6-6| ... | ... | @@ -1,15 +1,15 @@ |
| 1 | 1 | // Test that rustdoc will properly load in a theme file and display it in the theme selector. |
| 2 | 2 | |
| 3 | use run_make_support::{htmldocck, rustdoc, source_root}; | |
| 3 | use run_make_support::{fs_wrapper, htmldocck, rustdoc, source_root}; | |
| 4 | 4 | use std::path::Path; |
| 5 | 5 | |
| 6 | 6 | fn main() { |
| 7 | 7 | let out_dir = Path::new("rustdoc-themes"); |
| 8 | 8 | let test_css = "test.css"; |
| 9 | 9 | |
| 10 | let no_script = | |
| 11 | std::fs::read_to_string(source_root().join("src/librustdoc/html/static/css/noscript.css")) | |
| 12 | .unwrap(); | |
| 10 | let no_script = fs_wrapper::read_to_string( | |
| 11 | source_root().join("src/librustdoc/html/static/css/noscript.css"), | |
| 12 | ); | |
| 13 | 13 | |
| 14 | 14 | let mut test_content = String::new(); |
| 15 | 15 | let mut found_begin_light = false; |
| ... | ... | @@ -24,8 +24,8 @@ fn main() { |
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | assert!(!test_content.is_empty()); |
| 27 | std::fs::create_dir_all(&out_dir).unwrap(); | |
| 28 | std::fs::write(&test_css, test_content).unwrap(); | |
| 27 | fs_wrapper::create_dir_all(&out_dir); | |
| 28 | fs_wrapper::write(&test_css, test_content); | |
| 29 | 29 | |
| 30 | 30 | rustdoc().output(&out_dir).input("foo.rs").arg("--theme").arg(&test_css).run(); |
| 31 | 31 | htmldocck().arg(out_dir).arg("foo.rs").run(); |
tests/run-make/rustdoc-verify-output-files/rmake.rs+2-2| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | use std::fs::copy; | |
| 1 | use run_make_support::fs_wrapper::copy; | |
| 2 | 2 | use std::path::{Path, PathBuf}; |
| 3 | 3 | |
| 4 | 4 | use run_make_support::{copy_dir_all, recursive_diff, rustdoc}; |
| ... | ... | @@ -38,7 +38,7 @@ fn main() { |
| 38 | 38 | assert!(out_dir.join("foobar.json").is_file()); |
| 39 | 39 | |
| 40 | 40 | // Copy first json output to check if it's exactly same after second compilation. |
| 41 | copy(out_dir.join("foobar.json"), tmp_out_dir.join("foobar.json")).unwrap(); | |
| 41 | copy(out_dir.join("foobar.json"), tmp_out_dir.join("foobar.json")); | |
| 42 | 42 | |
| 43 | 43 | // Generate json doc on the same output. |
| 44 | 44 | generate_docs(&out_dir, JsonOutput::Yes); |
tests/run-make/wasm-custom-section/rmake.rs+2-2| ... | ... | @@ -1,13 +1,13 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | |
| 3 | use run_make_support::{rustc, wasmparser}; | |
| 3 | use run_make_support::{fs_wrapper, rustc, wasmparser}; | |
| 4 | 4 | use std::collections::HashMap; |
| 5 | 5 | |
| 6 | 6 | fn main() { |
| 7 | 7 | rustc().input("foo.rs").target("wasm32-wasip1").run(); |
| 8 | 8 | rustc().input("bar.rs").target("wasm32-wasip1").arg("-Clto").opt().run(); |
| 9 | 9 | |
| 10 | let file = std::fs::read("bar.wasm").unwrap(); | |
| 10 | let file = fs_wrapper::read("bar.wasm"); | |
| 11 | 11 | |
| 12 | 12 | let mut custom = HashMap::new(); |
| 13 | 13 | for payload in wasmparser::Parser::new(0).parse_all(&file) { |
tests/run-make/wasm-custom-sections-opt/rmake.rs+3-3| ... | ... | @@ -1,18 +1,18 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | |
| 3 | use run_make_support::{rustc, wasmparser}; | |
| 3 | use run_make_support::{fs_wrapper, rustc, wasmparser}; | |
| 4 | 4 | use std::collections::HashMap; |
| 5 | 5 | use std::path::Path; |
| 6 | 6 | |
| 7 | 7 | fn main() { |
| 8 | 8 | rustc().input("foo.rs").target("wasm32-wasip1").opt().run(); |
| 9 | 9 | |
| 10 | verify(&Path::new("foo.wasm")); | |
| 10 | verify(Path::new("foo.wasm")); | |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | fn verify(path: &Path) { |
| 14 | 14 | eprintln!("verify {path:?}"); |
| 15 | let file = std::fs::read(&path).unwrap(); | |
| 15 | let file = fs_wrapper::read(&path); | |
| 16 | 16 | |
| 17 | 17 | let mut custom = HashMap::new(); |
| 18 | 18 | for payload in wasmparser::Parser::new(0).parse_all(&file) { |
tests/run-make/wasm-export-all-symbols/rmake.rs+2-2| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | |
| 3 | use run_make_support::{rustc, wasmparser}; | |
| 3 | use run_make_support::{fs_wrapper, rustc, wasmparser}; | |
| 4 | 4 | use std::collections::HashMap; |
| 5 | 5 | use std::path::Path; |
| 6 | 6 | use wasmparser::ExternalKind::*; |
| ... | ... | @@ -33,7 +33,7 @@ fn test(args: &[&str]) { |
| 33 | 33 | |
| 34 | 34 | fn verify_exports(path: &Path, exports: &[(&str, wasmparser::ExternalKind)]) { |
| 35 | 35 | println!("verify {path:?}"); |
| 36 | let file = std::fs::read(path).unwrap(); | |
| 36 | let file = fs_wrapper::read(path); | |
| 37 | 37 | let mut wasm_exports = HashMap::new(); |
| 38 | 38 | for payload in wasmparser::Parser::new(0).parse_all(&file) { |
| 39 | 39 | let payload = payload.unwrap(); |
tests/run-make/wasm-import-module/rmake.rs+2-2| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | |
| 3 | use run_make_support::{rustc, wasmparser}; | |
| 3 | use run_make_support::{fs_wrapper, rustc, wasmparser}; | |
| 4 | 4 | use std::collections::HashMap; |
| 5 | 5 | use wasmparser::TypeRef::Func; |
| 6 | 6 | |
| ... | ... | @@ -8,7 +8,7 @@ fn main() { |
| 8 | 8 | rustc().input("foo.rs").target("wasm32-wasip1").run(); |
| 9 | 9 | rustc().input("bar.rs").target("wasm32-wasip1").arg("-Clto").opt().run(); |
| 10 | 10 | |
| 11 | let file = std::fs::read("bar.wasm").unwrap(); | |
| 11 | let file = fs_wrapper::read("bar.wasm"); | |
| 12 | 12 | |
| 13 | 13 | let mut imports = HashMap::new(); |
| 14 | 14 | for payload in wasmparser::Parser::new(0).parse_all(&file) { |
tests/run-make/wasm-panic-small/rmake.rs+2-2| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | #![deny(warnings)] |
| 3 | 3 | |
| 4 | use run_make_support::rustc; | |
| 4 | use run_make_support::{fs_wrapper, rustc}; | |
| 5 | 5 | |
| 6 | 6 | fn main() { |
| 7 | 7 | test("a"); |
| ... | ... | @@ -15,7 +15,7 @@ fn test(cfg: &str) { |
| 15 | 15 | |
| 16 | 16 | rustc().input("foo.rs").target("wasm32-wasip1").arg("-Clto").opt().cfg(cfg).run(); |
| 17 | 17 | |
| 18 | let bytes = std::fs::read("foo.wasm").unwrap(); | |
| 18 | let bytes = fs_wrapper::read("foo.wasm"); | |
| 19 | 19 | println!("{}", bytes.len()); |
| 20 | 20 | assert!(bytes.len() < 40_000); |
| 21 | 21 | } |
tests/run-make/wasm-spurious-import/rmake.rs+2-2| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | |
| 3 | use run_make_support::{rustc, wasmparser}; | |
| 3 | use run_make_support::{fs_wrapper, rustc, wasmparser}; | |
| 4 | 4 | use std::collections::HashMap; |
| 5 | 5 | |
| 6 | 6 | fn main() { |
| ... | ... | @@ -13,7 +13,7 @@ fn main() { |
| 13 | 13 | .arg("-Copt-level=z") |
| 14 | 14 | .run(); |
| 15 | 15 | |
| 16 | let file = std::fs::read("main.wasm").unwrap(); | |
| 16 | let file = fs_wrapper::read("main.wasm"); | |
| 17 | 17 | |
| 18 | 18 | let mut imports = HashMap::new(); |
| 19 | 19 | for payload in wasmparser::Parser::new(0).parse_all(&file) { |
tests/run-make/wasm-stringify-ints-small/rmake.rs+2-2| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | #![deny(warnings)] |
| 3 | 3 | |
| 4 | use run_make_support::rustc; | |
| 4 | use run_make_support::{fs_wrapper, rustc}; | |
| 5 | 5 | |
| 6 | 6 | fn main() { |
| 7 | 7 | rustc().input("foo.rs").target("wasm32-wasip1").arg("-Clto").opt().run(); |
| 8 | 8 | |
| 9 | let bytes = std::fs::read("foo.wasm").unwrap(); | |
| 9 | let bytes = fs_wrapper::read("foo.wasm"); | |
| 10 | 10 | println!("{}", bytes.len()); |
| 11 | 11 | assert!(bytes.len() < 50_000); |
| 12 | 12 | } |
tests/run-make/wasm-symbols-different-module/rmake.rs+2-2| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | |
| 3 | use run_make_support::{rustc, wasmparser}; | |
| 3 | use run_make_support::{fs_wrapper, rustc, wasmparser}; | |
| 4 | 4 | use std::collections::{HashMap, HashSet}; |
| 5 | 5 | use std::path::Path; |
| 6 | 6 | |
| ... | ... | @@ -23,7 +23,7 @@ fn test(file: &str, args: &[&str], expected_imports: &[(&str, &[&str])]) { |
| 23 | 23 | |
| 24 | 24 | rustc().input(file).target("wasm32-wasip1").args(args).run(); |
| 25 | 25 | |
| 26 | let file = std::fs::read(Path::new(file).with_extension("wasm")).unwrap(); | |
| 26 | let file = fs_wrapper::read(Path::new(file).with_extension("wasm")); | |
| 27 | 27 | |
| 28 | 28 | let mut imports = HashMap::new(); |
| 29 | 29 | for payload in wasmparser::Parser::new(0).parse_all(&file) { |
tests/run-make/wasm-symbols-not-exported/rmake.rs+2-2| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | |
| 3 | use run_make_support::{rustc, wasmparser}; | |
| 3 | use run_make_support::{fs_wrapper, rustc, wasmparser}; | |
| 4 | 4 | use std::path::Path; |
| 5 | 5 | |
| 6 | 6 | fn main() { |
| ... | ... | @@ -17,7 +17,7 @@ fn main() { |
| 17 | 17 | |
| 18 | 18 | fn verify_symbols(path: &Path) { |
| 19 | 19 | eprintln!("verify {path:?}"); |
| 20 | let file = std::fs::read(&path).unwrap(); | |
| 20 | let file = fs_wrapper::read(&path); | |
| 21 | 21 | |
| 22 | 22 | for payload in wasmparser::Parser::new(0).parse_all(&file) { |
| 23 | 23 | let payload = payload.unwrap(); |
tests/run-make/wasm-symbols-not-imported/rmake.rs+2-2| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | |
| 3 | use run_make_support::{rustc, wasmparser}; | |
| 3 | use run_make_support::{fs_wrapper, rustc, wasmparser}; | |
| 4 | 4 | use std::path::Path; |
| 5 | 5 | |
| 6 | 6 | fn main() { |
| ... | ... | @@ -16,7 +16,7 @@ fn main() { |
| 16 | 16 | |
| 17 | 17 | fn verify_symbols(path: &Path) { |
| 18 | 18 | eprintln!("verify {path:?}"); |
| 19 | let file = std::fs::read(&path).unwrap(); | |
| 19 | let file = fs_wrapper::read(&path); | |
| 20 | 20 | |
| 21 | 21 | for payload in wasmparser::Parser::new(0).parse_all(&file) { |
| 22 | 22 | let payload = payload.unwrap(); |
tests/run-make/windows-ws2_32/rmake.rs+2-3| ... | ... | @@ -3,8 +3,7 @@ |
| 3 | 3 | // Tests that WS2_32.dll is not unnecessarily linked, see issue #85441 |
| 4 | 4 | |
| 5 | 5 | use run_make_support::object::{self, read::Object}; |
| 6 | use run_make_support::rustc; | |
| 7 | use std::fs; | |
| 6 | use run_make_support::{fs_wrapper, rustc}; | |
| 8 | 7 | |
| 9 | 8 | fn main() { |
| 10 | 9 | rustc().input("empty.rs").run(); |
| ... | ... | @@ -15,7 +14,7 @@ fn main() { |
| 15 | 14 | } |
| 16 | 15 | |
| 17 | 16 | fn links_ws2_32(exe: &str) -> bool { |
| 18 | let binary_data = fs::read(exe).unwrap(); | |
| 17 | let binary_data = fs_wrapper::read(exe); | |
| 19 | 18 | let file = object::File::parse(&*binary_data).unwrap(); |
| 20 | 19 | for import in file.imports().unwrap() { |
| 21 | 20 | if import.library().eq_ignore_ascii_case(b"WS2_32.dll") { |