mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 00:13:21 +01:00
Fix some of the tests in tests::shell
(#12417)
# Description Some of the tests in `tests::shell` were using `sh` unnecessarily, and had `#[cfg(not(windows))]` when they should be testable on Windows if `sh` is not used. I also found that they were using `.expect()` incorrectly, under the assumption that that would check their output, when really an `assert_eq!` on the output is needed to do that. So these tests weren't even really working properly before. # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib`
This commit is contained in:
parent
0e36c43c64
commit
16cbed7d6e
@ -229,62 +229,46 @@ fn run_export_extern() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(windows))]
|
||||
fn run_in_login_mode() {
|
||||
let child_output = std::process::Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(format!(
|
||||
"{:?} --no-config-file --login --commands 'echo $nu.is-login'",
|
||||
nu_test_support::fs::executable_path()
|
||||
))
|
||||
let child_output = std::process::Command::new(nu_test_support::fs::executable_path())
|
||||
.args(["-n", "-l", "-c", "echo $nu.is-login"])
|
||||
.output()
|
||||
.expect("true");
|
||||
.expect("failed to run nu");
|
||||
|
||||
assert_eq!("true\n", String::from_utf8_lossy(&child_output.stdout));
|
||||
assert!(child_output.stderr.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(windows))]
|
||||
fn run_in_not_login_mode() {
|
||||
let child_output = std::process::Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(format!(
|
||||
"{:?} -c 'echo $nu.is-login'",
|
||||
nu_test_support::fs::executable_path()
|
||||
))
|
||||
let child_output = std::process::Command::new(nu_test_support::fs::executable_path())
|
||||
.args(["-c", "echo $nu.is-login"])
|
||||
.output()
|
||||
.expect("false");
|
||||
.expect("failed to run nu");
|
||||
|
||||
assert_eq!("false\n", String::from_utf8_lossy(&child_output.stdout));
|
||||
assert!(child_output.stderr.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(windows))]
|
||||
fn run_in_interactive_mode() {
|
||||
let child_output = std::process::Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(format!(
|
||||
"{:?} -i -c 'echo $nu.is-interactive'",
|
||||
nu_test_support::fs::executable_path()
|
||||
))
|
||||
let child_output = std::process::Command::new(nu_test_support::fs::executable_path())
|
||||
.args(["-i", "-c", "echo $nu.is-interactive"])
|
||||
.output()
|
||||
.expect("true");
|
||||
.expect("failed to run nu");
|
||||
|
||||
assert_eq!("true\n", String::from_utf8_lossy(&child_output.stdout));
|
||||
assert!(child_output.stderr.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(windows))]
|
||||
fn run_in_noninteractive_mode() {
|
||||
let child_output = std::process::Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(format!(
|
||||
"{:?} -c 'echo $nu.is-interactive'",
|
||||
nu_test_support::fs::executable_path()
|
||||
))
|
||||
let child_output = std::process::Command::new(nu_test_support::fs::executable_path())
|
||||
.args(["-c", "echo $nu.is-interactive"])
|
||||
.output()
|
||||
.expect("false");
|
||||
.expect("failed to run nu");
|
||||
|
||||
assert_eq!("false\n", String::from_utf8_lossy(&child_output.stdout));
|
||||
assert!(child_output.stderr.is_empty());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user