Update run-make-support/diff to new fs_wrapper API · rust-lang/rust@5f4111f (original) (raw)

`@@ -3,6 +3,7 @@ use similar::TextDiff;

`

3

3

`use std::path::{Path, PathBuf};

`

4

4

``

5

5

`use crate::drop_bomb::DropBomb;

`

``

6

`+

use crate::fs_wrapper;

`

6

7

``

7

8

`#[cfg(test)]

`

8

9

`mod tests;

`

`@@ -42,7 +43,7 @@ impl Diff {

`

42

43

`/// Specify the expected output for the diff from a file.

`

43

44

`pub fn expected_file<P: AsRef>(&mut self, path: P) -> &mut Self {

`

44

45

`let path = path.as_ref();

`

45

``

`-

let content = std::fs::read_to_string(path).expect("failed to read file");

`

``

46

`+

let content = fs_wrapper::read_to_string(path);

`

46

47

`let name = path.to_string_lossy().to_string();

`

47

48

``

48

49

`self.expected_file = Some(path.into());

`

`@@ -61,10 +62,7 @@ impl Diff {

`

61

62

`/// Specify the actual output for the diff from a file.

`

62

63

`pub fn actual_file<P: AsRef>(&mut self, path: P) -> &mut Self {

`

63

64

`let path = path.as_ref();

`

64

``

`-

let content = match std::fs::read_to_string(path) {

`

65

``

`-

Ok(c) => c,

`

66

``

`` -

Err(e) => panic!("failed to read {}: {:?}", path.display(), e),

``

67

``

`-

};

`

``

65

`+

let content = fs_wrapper::read_to_string(path);

`

68

66

`let name = path.to_string_lossy().to_string();

`

69

67

``

70

68

`self.actual = Some(content);

`

`@@ -112,7 +110,7 @@ impl Diff {

`

112

110

`if let Some(ref expected_file) = self.expected_file {

`

113

111

`if std::env::var("RUSTC_BLESS_TEST").is_ok() {

`

114

112

`` println!("Blessing {}", expected_file.display());

``

115

``

`-

std::fs::write(expected_file, actual).unwrap();

`

``

113

`+

fs_wrapper::write(expected_file, actual);

`

116

114

`return;

`

117

115

`}

`

118

116

`}

`