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

[pull] main from nushell:main #509

Merged
merged 1 commit into from
Oct 14, 2024
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
15 changes: 9 additions & 6 deletions crates/nu-command/tests/commands/do_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,28 @@ fn capture_errors_works() {
assert!(actual.err.contains("column_not_found"));
}

// TODO: need to add tests under display_error.exit_code = true
#[test]
fn capture_errors_works_for_external() {
let actual = nu!("do -c {nu --testbin fail}");
assert!(actual.err.contains("exited with code"));
assert_eq!(actual.out, "");
assert!(!actual.status.success());
assert!(!actual.err.contains("exited with code"));
}

// TODO: need to add tests under display_error.exit_code = true
#[test]
fn capture_errors_works_for_external_with_pipeline() {
let actual = nu!("do -c {nu --testbin fail} | echo `text`");
assert!(actual.err.contains("exited with code"));
assert_eq!(actual.out, "");
assert!(!actual.status.success());
assert!(!actual.err.contains("exited with code"));
}

// TODO: need to add tests under display_error.exit_code = true
#[test]
fn capture_errors_works_for_external_with_semicolon() {
let actual = nu!(r#"do -c {nu --testbin fail}; echo `text`"#);
assert!(actual.err.contains("exited with code"));
assert_eq!(actual.out, "");
assert!(!actual.status.success());
assert!(!actual.err.contains("exited with code"));
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/nu-protocol/src/config/display_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl DisplayErrors {
impl Default for DisplayErrors {
fn default() -> Self {
Self {
exit_code: true,
exit_code: false,
termination_signal: true,
}
}
Expand Down
6 changes: 4 additions & 2 deletions tests/shell/pipeline/commands/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,16 +627,18 @@ fn exit_code_stops_execution_closure() {
assert!(actual.err.contains("exited with code 1"));
}

// TODO: need to add tests under display_error.exit_code = true
#[test]
fn exit_code_stops_execution_custom_command() {
let actual = nu!("def cmd [] { nu -c 'exit 42'; 'ok1' }; cmd; print 'ok2'");
assert!(actual.out.is_empty());
assert!(actual.err.contains("exited with code 42"));
assert!(!actual.err.contains("exited with code 42"));
}

// TODO: need to add tests under display_error.exit_code = true
#[test]
fn exit_code_stops_execution_for_loop() {
let actual = nu!("for x in [0 1] { nu -c 'exit 42'; print $x }");
assert!(actual.out.is_empty());
assert!(actual.err.contains("exited with code 42"));
assert!(!actual.err.contains("exited with code 42"));
}
Loading