-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[target-spec-miette] switch fixtures to snapbox
I like `cargo insta`, but snapbox's SVGs are awesome and worth recommending.
- Loading branch information
1 parent
10066d2
commit fe3e11b
Showing
29 changed files
with
555 additions
and
112 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,20 @@ | ||
// Copyright (c) The cargo-guppy Contributors | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
|
||
use crate::helpers::bind_insta_settings; | ||
use crate::helpers::snapbox_assert_ansi; | ||
use datatest_stable::Utf8Path; | ||
use target_spec_miette::IntoMietteDiagnostic; | ||
|
||
pub(crate) fn expr_invalid(path: &Utf8Path, contents: String) -> datatest_stable::Result<()> { | ||
std::env::set_var("CLICOLOR_FORCE", "1"); | ||
|
||
let (_guard, insta_prefix) = | ||
bind_insta_settings(path, "../datatest-snapshot/snapshots/expr-invalid"); | ||
|
||
let error = target_spec::TargetSpec::new(contents.trim_end().to_owned()) | ||
.expect_err("expected input to fail"); | ||
|
||
let diagnostic = error.into_diagnostic(); | ||
insta::assert_snapshot!( | ||
format!("{insta_prefix}-display"), | ||
// This displays fancy output. Note the use of assert_snapshot, not | ||
// assert_debug_snapshot, since the latter uses the pretty-printed Debug | ||
// (which doesn't do what you would expect with miette/anyhow etc). | ||
format!("{:?}", miette::Report::new_boxed(diagnostic)), | ||
); | ||
// Use Debug output on the report to get the nicely formatted output. | ||
let output = format!("{:?}", miette::Report::new_boxed(diagnostic)); | ||
|
||
snapbox_assert_ansi("expr-invalid", path, output); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 1 addition & 5 deletions
6
...om-invalid/invalid-arch.json-display.snap → ...napshots/custom-invalid/invalid-arch.ansi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...t-spec-miette/tests/datatest-snapshot/snapshots/custom-invalid/invalid-arch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 1 addition & 5 deletions
6
...-invalid/invalid-endian.json-display.snap → ...pshots/custom-invalid/invalid-endian.ansi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.