Skip to content

Commit

Permalink
[target-spec-miette] add colors to snapshots
Browse files Browse the repository at this point in the history
A little harder to read, but more useful.
  • Loading branch information
sunshowers committed Jan 4, 2025
1 parent f750135 commit 10066d2
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 52 deletions.
2 changes: 2 additions & 0 deletions target-spec-miette/tests/datatest-snapshot/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use target_spec::TargetFeatures;
use target_spec_miette::IntoMietteDiagnostic;

pub(crate) fn custom_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/custom-invalid");

Expand Down
2 changes: 2 additions & 0 deletions target-spec-miette/tests/datatest-snapshot/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ 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");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
source: target-spec-miette/tests/snapshot/custom.rs
source: target-spec-miette/tests/datatest-snapshot/custom.rs
expression: "format!(\"{:?}\", miette::Report::new_boxed(diagnostic))"
snapshot_kind: text
---
× error deserializing custom target JSON for `my-target`
[31m×[0m error deserializing custom target JSON for `my-target`
╭─[2:13]
1 │ {
2"arch": 123,
· ▲
· ╰── invalid type: integer `123`, expected a string
3"cpu": "x86-64",
[2m1[0m │ {
[2m2[0m"arch": 123,
· [35;1m[0m
· [35;1m╰── [35;1minvalid type: integer `123`, expected a string[0m[0m
[2m3[0m"cpu": "x86-64",
╰────
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
source: target-spec-miette/tests/snapshot/custom.rs
source: target-spec-miette/tests/datatest-snapshot/custom.rs
expression: "format!(\"{:?}\", miette::Report::new_boxed(diagnostic))"
snapshot_kind: text
---
× error deserializing custom target JSON for `my-target`
[31m×[0m error deserializing custom target JSON for `my-target`
╭─[32:29]
31 │ },
32"target-endian": "middle",
· ▲
· ╰── unknown variant `middle`, expected `little` or `big`
33"target-family": ["unix"],
[2m31[0m │ },
[2m32[0m"target-endian": "middle",
· [35;1m[0m
· [35;1m╰── [35;1munknown variant `middle`, expected `little` or `big`[0m[0m
[2m33[0m"target-family": ["unix"],
╰────
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
source: target-spec-miette/tests/snapshot/custom.rs
source: target-spec-miette/tests/datatest-snapshot/custom.rs
expression: "format!(\"{:?}\", miette::Report::new_boxed(diagnostic))"
snapshot_kind: text
---
× error deserializing custom target JSON for `my-target`
[31m×[0m error deserializing custom target JSON for `my-target`
╭─[33:27]
32"target-endian": "big",
33"target-family": "none",
· ▲
· ╰── invalid type: string "none", expected a sequence
34"target-mcount": "_mcount",
[2m32[0m"target-endian": "big",
[2m33[0m"target-family": "none",
· [35;1m[0m
· [35;1m╰── [35;1minvalid type: string "none", expected a sequence[0m[0m
[2m34[0m"target-mcount": "_mcount",
╰────
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
source: target-spec-miette/tests/snapshot/custom.rs
source: target-spec-miette/tests/datatest-snapshot/custom.rs
expression: "format!(\"{:?}\", miette::Report::new_boxed(diagnostic))"
snapshot_kind: text
---
× error deserializing custom target JSON for `my-target`
[31m×[0m error deserializing custom target JSON for `my-target`
╭─[52:30]
51 │ ],
52"target-pointer-width": "xx",
· ▲
· ╰── error parsing as integer: invalid digit found in string
53"supports-xray": true,
[2m51[0m │ ],
[2m52[0m"target-pointer-width": "xx",
· [35;1m[0m
· [35;1m╰── [35;1merror parsing as integer: invalid digit found in string[0m[0m
[2m53[0m"supports-xray": true,
╰────
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
source: target-spec-miette/tests/snapshot/custom.rs
source: target-spec-miette/tests/datatest-snapshot/custom.rs
expression: "format!(\"{:?}\", miette::Report::new_boxed(diagnostic))"
snapshot_kind: text
---
× error deserializing custom target JSON for `my-target`
[31m×[0m error deserializing custom target JSON for `my-target`
╭─[35:1]
34"target-pointer-width": "64"
35 │ }
·
· ╰── missing field `arch`
[2m34[0m"target-pointer-width": "64"
[2m35[0m │ }
· [35;1m▲[0m
· [35;1m╰── [35;1mmissing field `arch`[0m[0m
╰────
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
source: target-spec-miette/tests/snapshot/custom.rs
source: target-spec-miette/tests/datatest-snapshot/custom.rs
expression: "format!(\"{:?}\", miette::Report::new_boxed(diagnostic))"
snapshot_kind: text
---
× error deserializing custom target JSON for `my-target`
[31m×[0m error deserializing custom target JSON for `my-target`
╭─[40:13]
39"leak",
40"memory",
· ▲
· ╰── EOF while parsing a value
[2m39[0m"leak",
[2m40[0m"memory",
· [35;1m[0m
· [35;1m╰── [35;1mEOF while parsing a value[0m[0m
╰────
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ source: target-spec-miette/tests/datatest-snapshot/expr.rs
expression: "format!(\"{:?}\", miette::Report::new_boxed(diagnostic))"
snapshot_kind: text
---
× error parsing cfg() expression
[31m×[0m error parsing cfg() expression
╭────
1cfg(target_does_not_exist = "unix")
· ──────────┬──────────
· ╰── expected one of `target_arch`, `target_feature`, `target_os`, `target_family`, `target_env`, `target_endian`, `target_has_atomic`, `target_pointer_width`, `target_vendor` here
[2m1[0mcfg(target_does_not_exist = "unix")
· [35;1m ──────────┬──────────[0m
· [35;1m╰── [35;1mexpected one of `target_arch`, `target_feature`, `target_os`, `target_family`, `target_env`, `target_endian`, `target_has_atomic`, `target_pointer_width`, `target_vendor` here[0m[0m
╰────
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ source: target-spec-miette/tests/datatest-snapshot/expr.rs
expression: "format!(\"{:?}\", miette::Report::new_boxed(diagnostic))"
snapshot_kind: text
---
× error parsing cfg() expression
[31m×[0m error parsing cfg() expression
╭────
1cfg(unix
· ┬
· ╰── expected one of `=`, `,`, `)` here
[2m1[0mcfg(unix
· [35;1m[0m
· [35;1m╰── [35;1mexpected one of `=`, `,`, `)` here[0m[0m
╰────
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ source: target-spec-miette/tests/datatest-snapshot/expr.rs
expression: "format!(\"{:?}\", miette::Report::new_boxed(diagnostic))"
snapshot_kind: text
---
× error parsing cfg() expression
[31m×[0m error parsing cfg() expression
╭────
1cfg(target_os = none)
· ──┬─
· ╰── expected a `"` here
[2m1[0mcfg(target_os = none)
· [35;1m ──┬─[0m
· [35;1m╰── [35;1mexpected a `"` here[0m[0m
╰────

0 comments on commit 10066d2

Please sign in to comment.