nushell/crates/nu-command/tests/commands/redirection.rs
JT 74a73f9838
Stdout/Stderr redirection (#7185)
This adds new pipeline connectors called out> and err> which redirect either stdout or stderr to a file. You can also use out+err> (or err+out>) to redirect both streams into a file.
2022-11-23 07:26:13 +13:00

67 lines
1.5 KiB
Rust

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(),
"cat asdfasdfasdf.txt err> a; cat a"
);
assert!(output.err.contains("asdfasdfasdf.txt"));
})
}
#[cfg(windows)]
#[test]
fn redirect_err() {
Playground::setup("redirect_err_test", |dirs, _sandbox| {
let output = nu!(
cwd: dirs.test(),
"type asdfasdfasdf.txt err> a; type a"
);
assert!(output.err.contains("asdfasdfasdf.txt"));
})
}
#[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"
);
assert!(output.err.contains("asdfasdfasdf.txt"));
})
}
#[cfg(windows)]
#[test]
fn redirect_outerr() {
Playground::setup("redirect_outerr_test", |dirs, _sandbox| {
let output = nu!(
cwd: dirs.test(),
"type asdfasdfasdf.txt out+err> a; type a"
);
assert!(output.err.contains("asdfasdfasdf.txt"));
})
}
#[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"));
})
}