mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
Loops return external stream when external command failed. (#8646)
This commit is contained in:
@ -28,3 +28,27 @@ fn for_break_on_external_failed() {
|
||||
// so our output will be `1`
|
||||
assert_eq!(actual.out, "1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn failed_for_should_break_running() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"
|
||||
for i in 1..2 {
|
||||
nu --testbin fail
|
||||
}
|
||||
print 3"#
|
||||
);
|
||||
assert!(!actual.out.contains('3'));
|
||||
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"
|
||||
let x = [1 2]
|
||||
for i in $x {
|
||||
nu --testbin fail
|
||||
}
|
||||
print 3"#
|
||||
);
|
||||
assert!(!actual.out.contains('3'));
|
||||
}
|
||||
|
@ -40,3 +40,22 @@ fn loop_break_on_external_failed() {
|
||||
// so our output will be `1`.
|
||||
assert_eq!(actual.out, "1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn failed_loop_should_break_running() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"
|
||||
mut total = 0;
|
||||
loop {
|
||||
if $total == 3 {
|
||||
break;
|
||||
} else {
|
||||
$total += 1;
|
||||
}
|
||||
nu --testbin fail;
|
||||
}
|
||||
print 3"#
|
||||
);
|
||||
assert!(!actual.out.contains('3'));
|
||||
}
|
||||
|
@ -31,3 +31,12 @@ fn while_break_on_external_failed() {
|
||||
// so our output will be `1`
|
||||
assert_eq!(actual.out, "1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn failed_while_should_break_running() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
"mut total = 0; while $total < 2 { $total = $total + 1; nu --testbin fail }; print 3"
|
||||
);
|
||||
assert!(!actual.out.contains('3'));
|
||||
}
|
||||
|
Reference in New Issue
Block a user