Skip to content

Commit 50fcd7e

Browse files
committed
minor refactors
1 parent 15bb2e3 commit 50fcd7e

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

tests/tools/src/lib.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -872,8 +872,6 @@ impl<'a> Drop for Env<'a> {
872872
#[cfg(test)]
873873
mod tests {
874874
use super::*;
875-
use std::fs::File;
876-
use std::io::{Read, Write};
877875

878876
#[test]
879877
fn parse_version() {
@@ -903,22 +901,12 @@ mod tests {
903901

904902
// Create the files.
905903
for path in paths {
906-
File::options()
907-
.write(true)
908-
.create_new(true)
909-
.open(path)
910-
.expect("can create file")
911-
.write_all(CONFIG_DATA)
912-
.expect("can write contents");
904+
std::fs::write(path, CONFIG_DATA).expect("can write contents");
913905
}
914906

915907
// Verify the files. This is mostly to show we really made a `\\?\...\NUL` on Windows.
916908
for path in paths {
917-
let mut buf = Vec::with_capacity(CONFIG_DATA.len());
918-
File::open(path)
919-
.expect("the file really exists")
920-
.read_to_end(&mut buf)
921-
.expect("can read contents");
909+
let buf = std::fs::read(path).expect("the file really exists");
922910
assert_eq!(buf, CONFIG_DATA, "File {path:?} should be created");
923911
}
924912
}

0 commit comments

Comments
 (0)