mirror of
https://github.com/nushell/nushell.git
synced 2024-11-23 00:43:33 +01:00
d735607ac8
# Description This is an attempt to isolate the unit tests from whatever might be in the user's config. If the user's config is broken in some way or incompatible with this version (for example, especially if there are plugins that aren't built for this version), tests can spuriously fail. This makes tests more reliably pass the same way they would on CI even if the user has config, and should also make them run faster. I think this is _good enough_, but I still think we should have a specific config dir env variable for nushell specifically (rather than having to use `XDG_CONFIG_HOME`, which would mess with other things) and then we can just have `nu-test-support` set that to a temporary dir containing the shipped default config files. # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib`
59 lines
1.4 KiB
Rust
59 lines
1.4 KiB
Rust
use nu_test_support::playground::Playground;
|
|
use nu_test_support::{nu, pipeline};
|
|
|
|
#[test]
|
|
fn basic_exec() {
|
|
Playground::setup("test_exec_1", |dirs, _| {
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
nu -n -c 'exec nu --testbin cococo a b c'
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "a b c");
|
|
})
|
|
}
|
|
|
|
#[test]
|
|
fn exec_complex_args() {
|
|
Playground::setup("test_exec_2", |dirs, _| {
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
nu -n -c 'exec nu --testbin cococo b --bar=2 -sab --arwr - -DTEEE=aasd-290 -90 --'
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "b --bar=2 -sab --arwr - -DTEEE=aasd-290 -90 --");
|
|
})
|
|
}
|
|
|
|
#[test]
|
|
fn exec_fail_batched_short_args() {
|
|
Playground::setup("test_exec_3", |dirs, _| {
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
nu -n -c 'exec nu --testbin cococo -ab 10'
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "");
|
|
})
|
|
}
|
|
|
|
#[test]
|
|
fn exec_misc_values() {
|
|
Playground::setup("test_exec_4", |dirs, _| {
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
nu -n -c 'let x = "abc"; exec nu --testbin cococo $x ...[ a b c ]'
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "abc a b c");
|
|
})
|
|
}
|