mirror of
https://github.com/nushell/nushell
synced 2024-12-31 23:39:00 +00:00
530ff3893e
* make capture error works better in do command * remove into string test because we have no way to generate Value::Error for now
61 lines
1.3 KiB
Rust
61 lines
1.3 KiB
Rust
use nu_test_support::{nu, pipeline};
|
|
|
|
#[test]
|
|
fn capture_errors_works() {
|
|
let actual = nu!(
|
|
cwd: ".", pipeline(
|
|
r#"
|
|
do -c {$env.use}
|
|
"#
|
|
));
|
|
|
|
assert!(actual.err.contains("column_not_found"));
|
|
}
|
|
|
|
#[test]
|
|
fn capture_errors_works_for_external() {
|
|
let actual = nu!(
|
|
cwd: ".", pipeline(
|
|
r#"
|
|
do -c {nu --testbin fail}
|
|
"#
|
|
));
|
|
assert!(actual.err.contains("External command runs to failed"));
|
|
assert_eq!(actual.out, "");
|
|
}
|
|
|
|
#[test]
|
|
fn capture_errors_works_for_external_with_pipeline() {
|
|
let actual = nu!(
|
|
cwd: ".", pipeline(
|
|
r#"
|
|
do -c {nu --testbin fail} | echo `text`
|
|
"#
|
|
));
|
|
assert!(actual.err.contains("External command runs to failed"));
|
|
assert_eq!(actual.out, "");
|
|
}
|
|
|
|
#[test]
|
|
fn capture_errors_works_for_external_with_semicolon() {
|
|
let actual = nu!(
|
|
cwd: ".", pipeline(
|
|
r#"
|
|
do -c {nu --testbin fail}; echo `text`
|
|
"#
|
|
));
|
|
assert!(actual.err.contains("External command runs to failed"));
|
|
assert_eq!(actual.out, "");
|
|
}
|
|
|
|
#[test]
|
|
fn do_with_semicolon_break_on_failed_external() {
|
|
let actual = nu!(
|
|
cwd: ".", pipeline(
|
|
r#"
|
|
do { nu --not_exist_flag }; `text`
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "");
|
|
}
|