Skip to content

Commit

Permalink
fix(test): make test output consistent across OSes
Browse files Browse the repository at this point in the history
  • Loading branch information
max-heller committed Jun 25, 2024
1 parent e9a0427 commit 4c51469
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ to = "markdown"
insta::assert_snapshot!(book, @r###"
├─ log output
│ INFO mdbook::book: Running the pandoc backend
│ WARN mdbook_pandoc::preprocess: Failed to resolve image link 'https://doesnotexist.fake/main.yml?style=flat-square' in chapter 'Some Chapter': could not fetch remote image: https://doesnotexist.fake/main.yml?style=flat-square: Dns Failed: resolve dns name 'doesnotexist.fake:443': failed to lookup address information: nodename nor servname provided, or not known
│ WARN mdbook_pandoc::preprocess: Failed to resolve image link 'https://doesnotexist.fake/main.yml?style=flat-square' in chapter 'Some Chapter': could not fetch remote image: Dns Failed
│ WARN mdbook_pandoc::preprocess: Replacing image with description
│ INFO mdbook_pandoc::pandoc::renderer: Wrote output to book/markdown/book.md
├─ markdown/book.md
Expand Down
7 changes: 6 additions & 1 deletion src/preprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ struct UnresolvableRemoteImage {

impl fmt::Display for UnresolvableRemoteImage {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "could not fetch remote image: {:#}", self.err)
if cfg!(test) {
// in tests, print less verbose error message to be consistent across operating systems
write!(f, "could not fetch remote image: {}", self.err.kind())
} else {
write!(f, "could not fetch remote image: {}", self.err)
}
}
}

Expand Down

0 comments on commit 4c51469

Please sign in to comment.