mirror of
https://github.com/nushell/nushell.git
synced 2024-12-27 17:39:15 +01:00
12991cd36f
# Description
This fixes issues with trying to run the tests with a terminal that is
small enough to cause errors to wrap around, or in cases where the test
environment might produce strings that are reasonably expected to wrap
around anyway. "Fancy" errors are too fancy for tests to work
predictably 😉
cc @abusch
# User-Facing Changes
- Added `--error-style` option for use with `--commands` (like
`--table-mode`)
# Tests + Formatting
Surprisingly, all of the tests pass, including in small windows! I only
had to make one change to a test for `error make` which was looking for
the box drawing characters miette uses to determine whether the span
label was showing up - but the plain error style output is even better
and easier to match on, so this test is actually more specific now.
43 lines
953 B
Rust
43 lines
953 B
Rust
use nu_test_support::nu;
|
|
|
|
#[test]
|
|
fn error_label_works() {
|
|
let actual = nu!("error make {msg:foo label:{text:unseen}}");
|
|
|
|
assert!(actual
|
|
.err
|
|
.contains("label at line 1, columns 1 to 10: unseen"));
|
|
}
|
|
|
|
#[test]
|
|
fn no_span_if_unspanned() {
|
|
let actual = nu!("error make -u {msg:foo label:{text:unseen}}");
|
|
|
|
assert!(!actual.err.contains("unseen"));
|
|
}
|
|
|
|
#[test]
|
|
fn error_start_bigger_than_end_should_fail() {
|
|
let actual = nu!("
|
|
error make {
|
|
msg: foo
|
|
label: {
|
|
text: bar
|
|
span: {start: 456 end: 123}
|
|
}
|
|
}
|
|
");
|
|
|
|
assert!(!actual.err.contains("invalid error format"));
|
|
assert!(!actual
|
|
.err
|
|
.contains("`$.label.start` should be smaller than `$.label.end`"));
|
|
}
|
|
|
|
#[test]
|
|
fn check_help_line() {
|
|
let actual = nu!("error make {msg:foo help: `Custom help line`}");
|
|
|
|
assert!(actual.err.contains("Custom help line"));
|
|
}
|