Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use box-drawing characters in error messages #1798

Merged
merged 4 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading