nushell/crates/nu-command/tests/commands/interleave.rs
Devyn Cairns d735607ac8
Isolate tests from user config (#12437)
# 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`
2024-04-10 06:27:46 +08:00

13 lines
610 B
Rust

use nu_test_support::nu;
#[test]
fn interleave_external_commands() {
let result = nu!("interleave \
{ nu -n -c 'print hello; print world' | lines | each { 'greeter: ' ++ $in } } \
{ nu -n -c 'print nushell; print rocks' | lines | each { 'evangelist: ' ++ $in } } | \
each { print }; null");
assert!(result.out.contains("greeter: hello"), "{}", result.out);
assert!(result.out.contains("greeter: world"), "{}", result.out);
assert!(result.out.contains("evangelist: nushell"), "{}", result.out);
assert!(result.out.contains("evangelist: rocks"), "{}", result.out);
}