-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make config code highlighter error more friendly (#152)
* Change opts test layout * Show existing opaque error * Improve error message for config code highlighter
- Loading branch information
1 parent
cc3ae7f
commit dde2a42
Showing
6 changed files
with
133 additions
and
13 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
macro_rules! snapshot_config_parse_error { | ||
( $( ($test_name:ident, $md_text:ident) ),* $(,)? ) => { | ||
$( | ||
#[test] | ||
fn $test_name() { | ||
let err = ::toml::from_str::<$crate::opts::Config>($md_text).unwrap_err(); | ||
|
||
::insta::with_settings!({ | ||
description => $md_text, | ||
}, { | ||
::insta::assert_display_snapshot!(err); | ||
}); | ||
} | ||
)* | ||
} | ||
} | ||
|
||
const UNKNOWN_THEME: &str = r#"light-theme.code-highlighter = "doesnt-exist""#; | ||
const INVALID_THEME_TY: &str = "light-theme.code-highlighter = []"; | ||
|
||
snapshot_config_parse_error!( | ||
(unknown_theme, UNKNOWN_THEME), | ||
(invalid_theme_ty, INVALID_THEME_TY), | ||
); |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mod error_msg; | ||
mod parse; |
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
13 changes: 13 additions & 0 deletions
13
src/opts/tests/snapshots/inlyne__opts__tests__error_msg__invalid_theme_ty.snap
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
source: src/opts/tests/error_msg.rs | ||
description: "light-theme.code-highlighter = []" | ||
expression: err | ||
--- | ||
TOML parse error at line 1, column 32 | ||
| | ||
1 | light-theme.code-highlighter = [] | ||
| ^^ | ||
Expects either a default theme name or a path to a custom theme. E.g. | ||
default: "inspired-github" | ||
custom: { path = "/path/to/custom.tmTheme" } | ||
|
11 changes: 11 additions & 0 deletions
11
src/opts/tests/snapshots/inlyne__opts__tests__error_msg__unknown_theme.snap
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
source: src/opts/tests/error_msg.rs | ||
description: "light-theme.code-highlighter = \"doesnt-exist\"" | ||
expression: err | ||
--- | ||
TOML parse error at line 1, column 32 | ||
| | ||
1 | light-theme.code-highlighter = "doesnt-exist" | ||
| ^^^^^^^^^^^^^^ | ||
"doesnt-exist" didn't match any of the expected variants: ["base16-ocean-dark", "base16-eighties-dark", "base16-mocha-dark", "base16-ocean-light", "inspired-github", "solarized-dark", "solarized-light"] | ||
|