2022-11-22 19:26:13 +01:00
|
|
|
use nu_test_support::nu;
|
|
|
|
use nu_test_support::playground::Playground;
|
|
|
|
|
|
|
|
#[cfg(not(windows))]
|
|
|
|
#[test]
|
|
|
|
fn redirect_err() {
|
|
|
|
Playground::setup("redirect_err_test", |dirs, _sandbox| {
|
|
|
|
let output = nu!(
|
|
|
|
cwd: dirs.test(),
|
2022-11-24 04:58:15 +01:00
|
|
|
"cat asdfasdfasdf.txt err> a.txt; cat a.txt"
|
2022-11-22 19:26:13 +01:00
|
|
|
);
|
|
|
|
|
2022-11-24 04:58:15 +01:00
|
|
|
assert!(output.out.contains("asdfasdfasdf.txt"));
|
2022-11-22 19:26:13 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(windows)]
|
|
|
|
#[test]
|
|
|
|
fn redirect_err() {
|
|
|
|
Playground::setup("redirect_err_test", |dirs, _sandbox| {
|
|
|
|
let output = nu!(
|
|
|
|
cwd: dirs.test(),
|
2022-11-24 04:58:15 +01:00
|
|
|
"dir missingapplication err> a; (open a | size).bytes >= 16"
|
2022-11-22 19:26:13 +01:00
|
|
|
);
|
|
|
|
|
2022-11-24 04:58:15 +01:00
|
|
|
assert!(output.out.contains("true"));
|
2022-11-22 19:26:13 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(windows))]
|
|
|
|
#[test]
|
|
|
|
fn redirect_outerr() {
|
|
|
|
Playground::setup("redirect_outerr_test", |dirs, _sandbox| {
|
|
|
|
let output = nu!(
|
|
|
|
cwd: dirs.test(),
|
|
|
|
"cat asdfasdfasdf.txt out+err> a; cat a"
|
|
|
|
);
|
|
|
|
|
2022-11-24 04:58:15 +01:00
|
|
|
assert!(output.out.contains("asdfasdfasdf.txt"));
|
2022-11-22 19:26:13 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(windows)]
|
|
|
|
#[test]
|
|
|
|
fn redirect_outerr() {
|
|
|
|
Playground::setup("redirect_outerr_test", |dirs, _sandbox| {
|
|
|
|
let output = nu!(
|
|
|
|
cwd: dirs.test(),
|
2022-11-24 04:58:15 +01:00
|
|
|
"dir missingapplication out+err> a; (open a | size).bytes >= 16"
|
2022-11-22 19:26:13 +01:00
|
|
|
);
|
|
|
|
|
2022-11-24 04:58:15 +01:00
|
|
|
assert!(output.out.contains("true"));
|
2022-11-22 19:26:13 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn redirect_out() {
|
|
|
|
Playground::setup("redirect_out_test", |dirs, _sandbox| {
|
|
|
|
let output = nu!(
|
|
|
|
cwd: dirs.test(),
|
|
|
|
"echo 'hello' out> a; open a"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert!(output.out.contains("hello"));
|
|
|
|
})
|
|
|
|
}
|