Skip to content

Commit

Permalink
Use box-drawing characters in error messages (#1798)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Dec 29, 2023
1 parent e2c0d86 commit b188882
Show file tree
Hide file tree
Showing 20 changed files with 506 additions and 507 deletions.
8 changes: 4 additions & 4 deletions src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2311,10 +2311,10 @@ mod tests {
.to_string(),
"error: Internal error, this may indicate a bug in just: Lexer presumed character `-`
consider filing an issue: https://github.com/casey/just/issues/new
--> justfile:1:1
|
1 | !
| ^"
β€”β€”β–Ά justfile:1:1
β”‚
1 β”‚ !
β”‚ ^"
);
}
}
8 changes: 4 additions & 4 deletions src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<'src> ColorDisplay for Token<'src> {
f,
"{:width$}{} {}:{}:{}",
"",
color.context().paint("-->"),
color.context().paint("β€”β€”β–Ά"),
self.path.display(),
line_number,
self.column.ordinal(),
Expand All @@ -67,19 +67,19 @@ impl<'src> ColorDisplay for Token<'src> {
f,
"{:width$} {}",
"",
color.context().paint("|"),
color.context().paint("β”‚"),
width = line_number_width
)?;
writeln!(
f,
"{} {space_line}",
color.context().paint(&format!("{line_number} |"))
color.context().paint(&format!("{line_number} β”‚"))
)?;
write!(
f,
"{:width$} {}",
"",
color.context().paint("|"),
color.context().paint("β”‚"),
width = line_number_width
)?;
write!(
Expand Down
24 changes: 12 additions & 12 deletions tests/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ fn duplicate_attributes_are_disallowed() {
.stderr(
"
error: Recipe attribute `no-exit-message` first used on line 1 is duplicated on line 2
--> justfile:2:2
|
2 | [no-exit-message]
| ^^^^^^^^^^^^^^^
β€”β€”β–Ά justfile:2:2
β”‚
2 β”‚ [no-exit-message]
β”‚ ^^^^^^^^^^^^^^^
",
)
.status(1)
Expand Down Expand Up @@ -73,10 +73,10 @@ fn multiple_attributes_one_line_error_message() {
.stderr(
"
error: Expected ']' or ',', but found identifier
--> justfile:1:17
|
1 | [macos, windows linux]
| ^^^^^
β€”β€”β–Ά justfile:1:17
β”‚
1 β”‚ [macos, windows linux]
β”‚ ^^^^^
",
)
.status(1)
Expand All @@ -97,10 +97,10 @@ fn multiple_attributes_one_line_duplicate_check() {
.stderr(
"
error: Recipe attribute `linux` first used on line 1 is duplicated on line 2
--> justfile:2:2
|
2 | [linux]
| ^^^^^
β€”β€”β–Ά justfile:2:2
β”‚
2 β”‚ [linux]
β”‚ ^^^^^
",
)
.status(1)
Expand Down
16 changes: 8 additions & 8 deletions tests/byte_order_mark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ fn non_leading_byte_order_mark_produces_error() {
.stderr(
"
error: Expected \'@\', \'[\', comment, end of file, end of line, or identifier, but found byte order mark
--> justfile:3:1
|
3 | \u{feff}
| ^
β€”β€”β–Ά justfile:3:1
β”‚
3 β”‚ \u{feff}
β”‚ ^
")
.status(EXIT_FAILURE)
.run();
Expand All @@ -43,10 +43,10 @@ fn dont_mention_byte_order_mark_in_errors() {
.stderr(
"
error: Expected '@', '[', comment, end of file, end of line, or identifier, but found '{'
--> justfile:1:1
|
1 | {
| ^
β€”β€”β–Ά justfile:1:1
β”‚
1 β”‚ {
β”‚ ^
",
)
.status(EXIT_FAILURE)
Expand Down
56 changes: 28 additions & 28 deletions tests/conditional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ test! {
stdout: "",
stderr: "
error: Variable `b` not defined
--> justfile:1:9
|
1 | a := if b == '' { '' } else { '' }
| ^
β€”β€”β–Ά justfile:1:9
β”‚
1 β”‚ a := if b == '' { '' } else { '' }
β”‚ ^
",
status: EXIT_FAILURE,
}
Expand All @@ -80,10 +80,10 @@ test! {
stdout: "",
stderr: "
error: Variable `b` not defined
--> justfile:1:15
|
1 | a := if '' == b { '' } else { '' }
| ^
β€”β€”β–Ά justfile:1:15
β”‚
1 β”‚ a := if '' == b { '' } else { '' }
β”‚ ^
",
status: EXIT_FAILURE,
}
Expand All @@ -99,10 +99,10 @@ test! {
stdout: "",
stderr: "
error: Variable `b` not defined
--> justfile:1:20
|
1 | a := if '' == '' { b } else { '' }
| ^
β€”β€”β–Ά justfile:1:20
β”‚
1 β”‚ a := if '' == '' { b } else { '' }
β”‚ ^
",
status: EXIT_FAILURE,
}
Expand All @@ -118,10 +118,10 @@ test! {
stdout: "",
stderr: "
error: Variable `b` not defined
--> justfile:1:32
|
1 | a := if '' == '' { '' } else { b }
| ^
β€”β€”β–Ά justfile:1:32
β”‚
1 β”‚ a := if '' == '' { '' } else { b }
β”‚ ^
",
status: EXIT_FAILURE,
}
Expand All @@ -137,10 +137,10 @@ test! {
stdout: "",
stderr: "
error: Expected '!=', '==', '=~', '+', or '/', but found identifier
--> justfile:1:12
|
1 | a := if '' a '' { '' } else { b }
| ^
β€”β€”β–Ά justfile:1:12
β”‚
1 β”‚ a := if '' a '' { '' } else { b }
β”‚ ^
",
status: EXIT_FAILURE,
}
Expand Down Expand Up @@ -182,10 +182,10 @@ test! {
stdout: "",
stderr: "
error: Expected keyword `else` but found `end of line`
--> justfile:1:54
|
1 | TEST := if path_exists('/bin/bash') == 'true' {'yes'}
| ^
β€”β€”β–Ά justfile:1:54
β”‚
1 β”‚ TEST := if path_exists('/bin/bash') == 'true' {'yes'}
β”‚ ^
",
status: EXIT_FAILURE,
}
Expand All @@ -198,10 +198,10 @@ test! {
stdout: "",
stderr: "
error: Expected keyword `else` but found identifier `els`
--> justfile:1:55
|
1 | TEST := if path_exists('/bin/bash') == 'true' {'yes'} els {'no'}
| ^^^
β€”β€”β–Ά justfile:1:55
β”‚
1 β”‚ TEST := if path_exists('/bin/bash') == 'true' {'yes'} els {'no'}
β”‚ ^^^
",
status: EXIT_FAILURE,
}
24 changes: 12 additions & 12 deletions tests/delimiters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ test! {
justfile: "(]",
stderr: "
error: Mismatched closing delimiter `]`. (Did you mean to close the `(` on line 1?)
--> justfile:1:2
|
1 | (]
| ^
β€”β€”β–Ά justfile:1:2
β”‚
1 β”‚ (]
β”‚ ^
",
status: EXIT_FAILURE,
}
Expand All @@ -18,10 +18,10 @@ test! {
justfile: "]",
stderr: "
error: Unexpected closing delimiter `]`
--> justfile:1:1
|
1 | ]
| ^
β€”β€”β–Ά justfile:1:1
β”‚
1 β”‚ ]
β”‚ ^
",
status: EXIT_FAILURE,
}
Expand Down Expand Up @@ -98,10 +98,10 @@ test! {
stdout: "",
stderr: "
error: Unterminated interpolation
--> justfile:2:8
|
2 | echo {{ (
| ^^
β€”β€”β–Ά justfile:2:8
β”‚
2 β”‚ echo {{ (
β”‚ ^^
",
status: EXIT_FAILURE,
}
57 changes: 28 additions & 29 deletions tests/error_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ test! {
justfile: "[private]\n[linux]\nalias t := test\n\ntest:\n",
stderr: "
error: Alias t has an invalid attribute `linux`
--> justfile:3:7
|
3 | alias t := test
| ^
β€”β€”β–Ά justfile:3:7
β”‚
3 β”‚ alias t := test
β”‚ ^
",
status: EXIT_FAILURE,
}
Expand All @@ -18,10 +18,10 @@ test! {
justfile: "foo := if '' == '' { '' } arlo { '' }",
stderr: "
error: Expected keyword `else` but found identifier `arlo`
--> justfile:1:27
|
1 | foo := if '' == '' { '' } arlo { '' }
| ^^^^
β€”β€”β–Ά justfile:1:27
β”‚
1 β”‚ foo := if '' == '' { '' } arlo { '' }
β”‚ ^^^^
",
status: EXIT_FAILURE,
}
Expand All @@ -31,10 +31,10 @@ test! {
justfile: "&~",
stderr: "
error: Expected character `&`
--> justfile:1:2
|
1 | &~
| ^
β€”β€”β–Ά justfile:1:2
β”‚
1 β”‚ &~
β”‚ ^
",
status: EXIT_FAILURE,
}
Expand Down Expand Up @@ -63,10 +63,10 @@ fn file_path_is_indented_if_justfile_is_long() {
.stderr(
"
error: Expected '*', ':', '$', identifier, or '+', but found end of file
--> justfile:20:4
|
20 | foo
| ^
β€”β€”β–Ά justfile:20:4
β”‚
20 β”‚ foo
β”‚ ^
",
)
.run();
Expand All @@ -81,33 +81,32 @@ fn file_paths_are_relative() {
.stderr(format!(
"
error: Expected '*', ':', '$', identifier, or '+', but found end of file
--> foo{}bar.just:1:4
|
1 | baz
| ^
β€”β€”β–Ά foo{}bar.just:1:4
β”‚
1 β”‚ baz
β”‚ ^
",
MAIN_SEPARATOR
))
.run();
}

#[test]
#[cfg(not(windows))]
fn file_paths_not_in_subdir_are_absolute() {
Test::new()
.write("foo/justfile", "import '../bar.just'")
.write("bar.just", "baz")
.no_justfile()
.args(["--justfile", "foo/justfile"])
.status(EXIT_FAILURE)
.stderr_regex(format!(
"
error: Expected '*', ':', '$', identifier, or '+', but found end of file
--> {}.*{}bar.just:1:4
|
1 | baz
| ^
.stderr_regex(
r"error: Expected '\*', ':', '\$', identifier, or '\+', but found end of file
β€”β€”β–Ά /.*/bar.just:1:4
β”‚
1 β”‚ baz
β”‚ \^
",
MAIN_SEPARATOR, MAIN_SEPARATOR
))
)
.run();
}
8 changes: 4 additions & 4 deletions tests/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ fn print_error_from_parent_if_recipe_not_found_in_current() {
.stderr(
"
error: Variable `bar` not defined
--> justfile:2:9
|
2 | echo {{bar}}
| ^^^
β€”β€”β–Ά justfile:2:9
β”‚
2 β”‚ echo {{bar}}
β”‚ ^^^
",
)
.status(EXIT_FAILURE)
Expand Down
Loading

0 comments on commit b188882

Please sign in to comment.