2022-07-29 22:42:00 +02:00
|
|
|
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
|
|
|
use nu_test_support::playground::Playground;
|
|
|
|
use nu_test_support::{nu, nu_repl_code, pipeline};
|
2020-10-05 21:29:04 +02:00
|
|
|
|
2021-02-19 02:24:27 +01:00
|
|
|
#[cfg(feature = "which-support")]
|
|
|
|
mod environment;
|
|
|
|
|
2020-01-16 10:05:53 +01:00
|
|
|
mod pipeline;
|
2020-10-05 21:29:04 +02:00
|
|
|
|
2022-02-02 21:59:01 +01:00
|
|
|
//FIXME: jt: we need to focus some fixes on wix as the plugins will differ
|
|
|
|
#[ignore]
|
2020-10-05 21:29:04 +02:00
|
|
|
#[test]
|
|
|
|
fn plugins_are_declared_with_wix() {
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: ".", pipeline(
|
|
|
|
r#"
|
2020-10-13 23:22:49 +02:00
|
|
|
open Cargo.toml
|
|
|
|
| get bin.name
|
2022-04-07 15:41:09 +02:00
|
|
|
| str replace "nu_plugin_(extra|core)_(.*)" "nu_plugin_$2"
|
2020-10-13 23:22:49 +02:00
|
|
|
| drop
|
|
|
|
| sort-by
|
|
|
|
| wrap cargo | merge {
|
2020-10-13 01:18:39 +02:00
|
|
|
open wix/main.wxs --raw | from xml
|
2020-10-05 21:29:04 +02:00
|
|
|
| get Wix.children.Product.children.0.Directory.children.0
|
|
|
|
| where Directory.attributes.Id == "$(var.PlatformProgramFilesFolder)"
|
|
|
|
| get Directory.children.Directory.children.0 | last
|
|
|
|
| get Directory.children.Component.children
|
2022-02-17 12:40:24 +01:00
|
|
|
| each { |it| echo $it | first }
|
2020-10-05 21:29:04 +02:00
|
|
|
| skip
|
|
|
|
| where File.attributes.Name =~ "nu_plugin"
|
|
|
|
| str substring [_, -4] File.attributes.Name
|
|
|
|
| get File.attributes.Name
|
|
|
|
| sort-by
|
2020-10-13 01:18:39 +02:00
|
|
|
| wrap wix
|
|
|
|
}
|
|
|
|
| default wix _
|
2022-02-17 12:40:24 +01:00
|
|
|
| each { |it| if $it.wix != $it.cargo { 1 } { 0 } }
|
2020-10-05 21:29:04 +02:00
|
|
|
| math sum
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual.out, "0");
|
|
|
|
}
|
2021-12-21 00:08:41 +01:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[cfg(not(windows))]
|
|
|
|
fn do_not_panic_if_broken_pipe() {
|
|
|
|
// `nu -h | false`
|
|
|
|
// used to panic with a BrokenPipe error
|
|
|
|
let child_output = std::process::Command::new("sh")
|
|
|
|
.arg("-c")
|
|
|
|
.arg(format!(
|
|
|
|
"{:?} -h | false",
|
|
|
|
nu_test_support::fs::executable_path()
|
|
|
|
))
|
|
|
|
.output()
|
|
|
|
.expect("failed to execute process");
|
|
|
|
|
|
|
|
assert!(child_output.stderr.is_empty());
|
|
|
|
}
|
2022-07-29 22:42:00 +02:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn nu_lib_dirs_repl() {
|
|
|
|
Playground::setup("nu_lib_dirs_repl", |dirs, sandbox| {
|
|
|
|
sandbox
|
|
|
|
.mkdir("scripts")
|
|
|
|
.with_files(vec![FileWithContentToBeTrimmed(
|
|
|
|
"scripts/foo.nu",
|
|
|
|
r#"
|
|
|
|
let-env FOO = "foo"
|
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
|
|
|
let inp_lines = &[
|
|
|
|
r#"let-env NU_LIB_DIRS = [ ('scripts' | path expand) ]"#,
|
|
|
|
r#"source foo.nu"#,
|
|
|
|
r#"$env.FOO"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual_repl = nu!(cwd: dirs.test(), nu_repl_code(inp_lines));
|
|
|
|
|
|
|
|
assert!(actual_repl.err.is_empty());
|
|
|
|
assert_eq!(actual_repl.out, "foo");
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn nu_lib_dirs_script() {
|
|
|
|
Playground::setup("nu_lib_dirs_script", |dirs, sandbox| {
|
|
|
|
sandbox
|
|
|
|
.mkdir("scripts")
|
|
|
|
.with_files(vec![FileWithContentToBeTrimmed(
|
|
|
|
"scripts/foo.nu",
|
|
|
|
r#"
|
|
|
|
let-env FOO = "foo"
|
|
|
|
"#,
|
|
|
|
)])
|
|
|
|
.with_files(vec![FileWithContentToBeTrimmed(
|
|
|
|
"main.nu",
|
|
|
|
r#"
|
|
|
|
source foo.nu
|
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
|
|
|
let inp_lines = &[
|
|
|
|
r#"let-env NU_LIB_DIRS = [ ('scripts' | path expand) ]"#,
|
|
|
|
r#"source main.nu"#,
|
|
|
|
r#"$env.FOO"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual_repl = nu!(cwd: dirs.test(), nu_repl_code(inp_lines));
|
|
|
|
|
|
|
|
assert!(actual_repl.err.is_empty());
|
|
|
|
assert_eq!(actual_repl.out, "foo");
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn nu_lib_dirs_relative_repl() {
|
|
|
|
Playground::setup("nu_lib_dirs_relative_repl", |dirs, sandbox| {
|
|
|
|
sandbox
|
|
|
|
.mkdir("scripts")
|
|
|
|
.with_files(vec![FileWithContentToBeTrimmed(
|
|
|
|
"scripts/foo.nu",
|
|
|
|
r#"
|
|
|
|
let-env FOO = "foo"
|
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
|
|
|
let inp_lines = &[
|
|
|
|
r#"let-env NU_LIB_DIRS = [ 'scripts' ]"#,
|
|
|
|
r#"source foo.nu"#,
|
|
|
|
r#"$env.FOO"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual_repl = nu!(cwd: dirs.test(), nu_repl_code(inp_lines));
|
|
|
|
|
|
|
|
assert!(actual_repl.err.is_empty());
|
|
|
|
assert_eq!(actual_repl.out, "foo");
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn nu_lib_dirs_relative_script() {
|
|
|
|
Playground::setup("nu_lib_dirs_relative_script", |dirs, sandbox| {
|
|
|
|
sandbox
|
|
|
|
.mkdir("scripts")
|
|
|
|
.with_files(vec![FileWithContentToBeTrimmed(
|
|
|
|
"scripts/main.nu",
|
|
|
|
r#"
|
|
|
|
source ../foo.nu
|
|
|
|
"#,
|
|
|
|
)])
|
|
|
|
.with_files(vec![FileWithContentToBeTrimmed(
|
|
|
|
"foo.nu",
|
|
|
|
r#"
|
|
|
|
let-env FOO = "foo"
|
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
|
|
|
let inp_lines = &[
|
|
|
|
r#"let-env NU_LIB_DIRS = [ 'scripts' ]"#,
|
|
|
|
r#"source scripts/main.nu"#,
|
|
|
|
r#"$env.FOO"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual_repl = nu!(cwd: dirs.test(), nu_repl_code(inp_lines));
|
|
|
|
|
|
|
|
assert!(actual_repl.err.is_empty());
|
|
|
|
assert_eq!(actual_repl.out, "foo");
|
|
|
|
})
|
|
|
|
}
|