2022-07-29 20:42:00 +00:00
|
|
|
use nu_test_support::{nu, nu_repl_code, pipeline};
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn add_overlay() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[
|
|
|
|
r#"module spam { export def foo [] { "foo" } }"#,
|
|
|
|
r#"overlay add spam"#,
|
|
|
|
r#"foo"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert_eq!(actual.out, "foo");
|
2022-05-08 13:09:39 +00:00
|
|
|
assert_eq!(actual_repl.out, "foo");
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn add_overlay_env() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[
|
|
|
|
r#"module spam { export env FOO { "foo" } }"#,
|
|
|
|
r#"overlay add spam"#,
|
|
|
|
r#"$env.FOO"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert_eq!(actual.out, "foo");
|
2022-05-08 13:09:39 +00:00
|
|
|
assert_eq!(actual_repl.out, "foo");
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn add_overlay_from_file_decl() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[r#"overlay add samples/spam.nu"#, r#"foo"#];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert_eq!(actual.out, "foo");
|
2022-05-08 13:09:39 +00:00
|
|
|
assert_eq!(actual_repl.out, "foo");
|
|
|
|
}
|
|
|
|
|
|
|
|
// This one tests that the `nu_repl()` loop works correctly
|
|
|
|
#[test]
|
|
|
|
fn add_overlay_from_file_decl_cd() {
|
|
|
|
let inp = &[r#"cd samples"#, r#"overlay add spam.nu"#, r#"foo"#];
|
|
|
|
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-08 13:09:39 +00:00
|
|
|
|
|
|
|
assert_eq!(actual_repl.out, "foo");
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn add_overlay_from_file_alias() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[r#"overlay add samples/spam.nu"#, r#"bar"#];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert_eq!(actual.out, "bar");
|
2022-05-08 13:09:39 +00:00
|
|
|
assert_eq!(actual_repl.out, "bar");
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn add_overlay_from_file_env() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[r#"overlay add samples/spam.nu"#, r#"$env.BAZ"#];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert_eq!(actual.out, "baz");
|
2022-05-08 13:09:39 +00:00
|
|
|
assert_eq!(actual_repl.out, "baz");
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn add_overlay_scoped() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[
|
|
|
|
r#"module spam { export def foo [] { "foo" } }"#,
|
|
|
|
r#"do { overlay add spam }"#,
|
|
|
|
r#"foo"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-08 13:09:39 +00:00
|
|
|
|
|
|
|
assert!(!actual.err.is_empty());
|
|
|
|
#[cfg(windows)]
|
|
|
|
assert!(actual_repl.out != "foo");
|
|
|
|
#[cfg(not(windows))]
|
|
|
|
assert!(!actual_repl.err.is_empty());
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn update_overlay_from_module() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[
|
|
|
|
r#"module spam { export def foo [] { "foo" } }"#,
|
|
|
|
r#"overlay add spam"#,
|
|
|
|
r#"module spam { export def foo [] { "bar" } }"#,
|
|
|
|
r#"overlay add spam"#,
|
|
|
|
r#"foo"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert_eq!(actual.out, "bar");
|
2022-05-08 13:09:39 +00:00
|
|
|
assert_eq!(actual_repl.out, "bar");
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn update_overlay_from_module_env() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[
|
|
|
|
r#"module spam { export env FOO { "foo" } }"#,
|
|
|
|
r#"overlay add spam"#,
|
|
|
|
r#"module spam { export env FOO { "bar" } }"#,
|
|
|
|
r#"overlay add spam"#,
|
|
|
|
r#"$env.FOO"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert_eq!(actual.out, "bar");
|
2022-05-08 13:09:39 +00:00
|
|
|
assert_eq!(actual_repl.out, "bar");
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn remove_overlay() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[
|
|
|
|
r#"module spam { export def foo [] { "foo" } }"#,
|
|
|
|
r#"overlay add spam"#,
|
|
|
|
r#"overlay remove spam"#,
|
|
|
|
r#"foo"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert!(!actual.err.is_empty());
|
2022-05-08 13:09:39 +00:00
|
|
|
#[cfg(windows)]
|
|
|
|
assert!(actual_repl.out != "foo");
|
|
|
|
#[cfg(not(windows))]
|
|
|
|
assert!(!actual_repl.err.is_empty());
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn remove_last_overlay() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[
|
|
|
|
r#"module spam { export def foo [] { "foo" } }"#,
|
|
|
|
r#"overlay add spam"#,
|
|
|
|
r#"overlay remove"#,
|
|
|
|
r#"foo"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert!(!actual.err.is_empty());
|
2022-05-08 13:09:39 +00:00
|
|
|
#[cfg(windows)]
|
|
|
|
assert!(actual_repl.out != "foo");
|
|
|
|
#[cfg(not(windows))]
|
|
|
|
assert!(!actual_repl.err.is_empty());
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn remove_overlay_scoped() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[
|
|
|
|
r#"module spam { export def foo [] { "foo" } }"#,
|
|
|
|
r#"overlay add spam"#,
|
|
|
|
r#"do { overlay remove spam }"#,
|
|
|
|
r#"foo"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert_eq!(actual.out, "foo");
|
2022-05-08 13:09:39 +00:00
|
|
|
assert_eq!(actual_repl.out, "foo");
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn remove_overlay_env() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[
|
|
|
|
r#"module spam { export env FOO { "foo" } }"#,
|
|
|
|
r#"overlay add spam"#,
|
|
|
|
r#"overlay remove spam"#,
|
|
|
|
r#"$env.FOO"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert!(actual.err.contains("did you mean"));
|
2022-05-08 13:09:39 +00:00
|
|
|
assert!(actual_repl.err.contains("DidYouMean"));
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn remove_overlay_scoped_env() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[
|
|
|
|
r#"module spam { export env FOO { "foo" } }"#,
|
|
|
|
r#"overlay add spam"#,
|
|
|
|
r#"do { overlay remove spam }"#,
|
|
|
|
r#"$env.FOO"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert_eq!(actual.out, "foo");
|
2022-05-08 13:09:39 +00:00
|
|
|
assert_eq!(actual_repl.out, "foo");
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn list_default_overlay() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[r#"overlay list | last"#];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert_eq!(actual.out, "zero");
|
2022-05-08 13:09:39 +00:00
|
|
|
assert_eq!(actual_repl.out, "zero");
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn list_last_overlay() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[
|
|
|
|
r#"module spam { export def foo [] { "foo" } }"#,
|
|
|
|
r#"overlay add spam"#,
|
|
|
|
r#"overlay list | last"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert_eq!(actual.out, "spam");
|
2022-05-08 13:09:39 +00:00
|
|
|
assert_eq!(actual_repl.out, "spam");
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn list_overlay_scoped() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[
|
|
|
|
r#"module spam { export def foo [] { "foo" } }"#,
|
|
|
|
r#"overlay add spam"#,
|
|
|
|
r#"do { overlay list | last }"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert_eq!(actual.out, "spam");
|
2022-05-08 13:09:39 +00:00
|
|
|
assert_eq!(actual_repl.out, "spam");
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn remove_overlay_discard_decl() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[
|
|
|
|
r#"overlay add samples/spam.nu"#,
|
|
|
|
r#"def bagr [] { "bagr" }"#,
|
|
|
|
r#"overlay remove spam"#,
|
|
|
|
r#"bagr"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert!(!actual.err.is_empty());
|
2022-05-08 13:09:39 +00:00
|
|
|
#[cfg(windows)]
|
|
|
|
assert!(actual_repl.out != "bagr");
|
|
|
|
#[cfg(not(windows))]
|
|
|
|
assert!(!actual_repl.err.is_empty());
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn remove_overlay_discard_alias() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[
|
|
|
|
r#"overlay add samples/spam.nu"#,
|
|
|
|
r#"alias bagr = "bagr""#,
|
|
|
|
r#"overlay remove spam"#,
|
|
|
|
r#"bagr"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert!(!actual.err.is_empty());
|
2022-05-08 13:09:39 +00:00
|
|
|
#[cfg(windows)]
|
|
|
|
assert!(actual_repl.out != "bagr");
|
|
|
|
#[cfg(not(windows))]
|
|
|
|
assert!(!actual_repl.err.is_empty());
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn remove_overlay_discard_env() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[
|
|
|
|
r#"overlay add samples/spam.nu"#,
|
2022-07-29 20:42:00 +00:00
|
|
|
r#"let-env BAGR = `bagr`"#,
|
2022-05-08 13:09:39 +00:00
|
|
|
r#"overlay remove spam"#,
|
|
|
|
r#"$env.BAGR"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert!(actual.err.contains("did you mean"));
|
2022-05-08 13:09:39 +00:00
|
|
|
assert!(actual_repl.err.contains("DidYouMean"));
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
2022-05-24 21:22:17 +00:00
|
|
|
#[test]
|
|
|
|
fn remove_overlay_keep_decl() {
|
|
|
|
let inp = &[
|
|
|
|
r#"overlay add samples/spam.nu"#,
|
|
|
|
r#"def bagr [] { "bagr" }"#,
|
|
|
|
r#"overlay remove --keep-custom spam"#,
|
|
|
|
r#"bagr"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-24 21:22:17 +00:00
|
|
|
|
|
|
|
assert!(actual.out.contains("bagr"));
|
|
|
|
assert!(actual_repl.out.contains("bagr"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn remove_overlay_keep_alias() {
|
|
|
|
let inp = &[
|
|
|
|
r#"overlay add samples/spam.nu"#,
|
2022-07-29 20:42:00 +00:00
|
|
|
r#"alias bagr = `bagr`"#,
|
2022-05-24 21:22:17 +00:00
|
|
|
r#"overlay remove --keep-custom spam"#,
|
|
|
|
r#"bagr"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-24 21:22:17 +00:00
|
|
|
|
|
|
|
assert!(actual.out.contains("bagr"));
|
|
|
|
assert!(actual_repl.out.contains("bagr"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn remove_overlay_keep_env() {
|
|
|
|
let inp = &[
|
|
|
|
r#"overlay add samples/spam.nu"#,
|
2022-07-29 20:42:00 +00:00
|
|
|
r#"let-env BAGR = `bagr`"#,
|
2022-05-24 21:22:17 +00:00
|
|
|
r#"overlay remove --keep-custom spam"#,
|
|
|
|
r#"$env.BAGR"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-24 21:22:17 +00:00
|
|
|
|
|
|
|
assert!(actual.out.contains("bagr"));
|
|
|
|
assert!(actual_repl.out.contains("bagr"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn remove_overlay_keep_discard_overwritten_decl() {
|
|
|
|
let inp = &[
|
|
|
|
r#"overlay add samples/spam.nu"#,
|
|
|
|
r#"def foo [] { 'bar' }"#,
|
|
|
|
r#"overlay remove --keep-custom spam"#,
|
|
|
|
r#"foo"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-24 21:22:17 +00:00
|
|
|
|
|
|
|
assert!(!actual.err.is_empty());
|
|
|
|
#[cfg(windows)]
|
|
|
|
assert!(actual_repl.out != "bagr");
|
|
|
|
#[cfg(not(windows))]
|
|
|
|
assert!(!actual_repl.err.is_empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn remove_overlay_keep_discard_overwritten_alias() {
|
|
|
|
let inp = &[
|
|
|
|
r#"overlay add samples/spam.nu"#,
|
2022-07-29 20:42:00 +00:00
|
|
|
r#"alias bar = `baz`"#,
|
2022-05-24 21:22:17 +00:00
|
|
|
r#"overlay remove --keep-custom spam"#,
|
|
|
|
r#"bar"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-24 21:22:17 +00:00
|
|
|
|
|
|
|
assert!(!actual.err.is_empty());
|
|
|
|
#[cfg(windows)]
|
|
|
|
assert!(actual_repl.out != "bagr");
|
|
|
|
#[cfg(not(windows))]
|
|
|
|
assert!(!actual_repl.err.is_empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn remove_overlay_keep_discard_overwritten_env() {
|
|
|
|
let inp = &[
|
|
|
|
r#"overlay add samples/spam.nu"#,
|
2022-07-29 20:42:00 +00:00
|
|
|
r#"let-env BAZ = `bagr`"#,
|
2022-05-24 21:22:17 +00:00
|
|
|
r#"overlay remove --keep-custom spam"#,
|
|
|
|
r#"$env.BAZ"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-24 21:22:17 +00:00
|
|
|
|
|
|
|
assert!(actual.err.contains("did you mean"));
|
|
|
|
assert!(actual_repl.err.contains("DidYouMean"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn remove_overlay_keep_decl_in_latest_overlay() {
|
|
|
|
let inp = &[
|
|
|
|
r#"overlay add samples/spam.nu"#,
|
|
|
|
r#"def bagr [] { 'bagr' }"#,
|
|
|
|
r#"module eggs { }"#,
|
|
|
|
r#"overlay add eggs"#,
|
|
|
|
r#"overlay remove --keep-custom spam"#,
|
|
|
|
r#"bagr"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-24 21:22:17 +00:00
|
|
|
|
|
|
|
assert!(actual.out.contains("bagr"));
|
|
|
|
assert!(actual_repl.out.contains("bagr"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn remove_overlay_keep_alias_in_latest_overlay() {
|
|
|
|
let inp = &[
|
|
|
|
r#"overlay add samples/spam.nu"#,
|
2022-07-29 20:42:00 +00:00
|
|
|
r#"alias bagr = `bagr`"#,
|
2022-05-24 21:22:17 +00:00
|
|
|
r#"module eggs { }"#,
|
|
|
|
r#"overlay add eggs"#,
|
|
|
|
r#"overlay remove --keep-custom spam"#,
|
|
|
|
r#"bagr"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-24 21:22:17 +00:00
|
|
|
|
|
|
|
assert!(actual.out.contains("bagr"));
|
|
|
|
assert!(actual_repl.out.contains("bagr"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn remove_overlay_keep_env_in_latest_overlay() {
|
|
|
|
let inp = &[
|
|
|
|
r#"overlay add samples/spam.nu"#,
|
2022-07-29 20:42:00 +00:00
|
|
|
r#"let-env BAGR = `bagr`"#,
|
2022-05-24 21:22:17 +00:00
|
|
|
r#"module eggs { }"#,
|
|
|
|
r#"overlay add eggs"#,
|
|
|
|
r#"overlay remove --keep-custom spam"#,
|
|
|
|
r#"$env.BAGR"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-24 21:22:17 +00:00
|
|
|
|
|
|
|
assert!(actual.out.contains("bagr"));
|
|
|
|
assert!(actual_repl.out.contains("bagr"));
|
|
|
|
}
|
|
|
|
|
2022-05-07 19:39:22 +00:00
|
|
|
#[test]
|
|
|
|
fn preserve_overrides() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[
|
|
|
|
r#"overlay add samples/spam.nu"#,
|
|
|
|
r#"def foo [] { "new-foo" }"#,
|
|
|
|
r#"overlay remove spam"#,
|
|
|
|
r#"overlay add spam"#,
|
|
|
|
r#"foo"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert_eq!(actual.out, "new-foo");
|
2022-05-08 13:09:39 +00:00
|
|
|
assert_eq!(actual_repl.out, "new-foo");
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn reset_overrides() {
|
2022-05-08 13:09:39 +00:00
|
|
|
let inp = &[
|
|
|
|
r#"overlay add samples/spam.nu"#,
|
|
|
|
r#"def foo [] { "new-foo" }"#,
|
|
|
|
r#"overlay remove spam"#,
|
|
|
|
r#"overlay add samples/spam.nu"#,
|
|
|
|
r#"foo"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-07 19:39:22 +00:00
|
|
|
|
|
|
|
assert_eq!(actual.out, "foo");
|
2022-05-08 13:09:39 +00:00
|
|
|
assert_eq!(actual_repl.out, "foo");
|
2022-05-07 19:39:22 +00:00
|
|
|
}
|
2022-05-26 14:47:04 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn overlay_new() {
|
|
|
|
let inp = &[r#"overlay new spam"#, r#"overlay list | last"#];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-05-26 14:47:04 +00:00
|
|
|
|
|
|
|
assert_eq!(actual.out, "spam");
|
|
|
|
assert_eq!(actual_repl.out, "spam");
|
|
|
|
}
|
2022-07-11 20:58:28 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn overlay_keep_pwd() {
|
|
|
|
let inp = &[
|
|
|
|
r#"overlay new spam"#,
|
|
|
|
r#"cd samples"#,
|
|
|
|
r#"overlay remove --keep-env [ PWD ] spam"#,
|
|
|
|
r#"$env.PWD | path basename"#,
|
|
|
|
];
|
|
|
|
|
|
|
|
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
2022-07-29 20:42:00 +00:00
|
|
|
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
2022-07-11 20:58:28 +00:00
|
|
|
|
|
|
|
assert_eq!(actual.out, "samples");
|
|
|
|
assert_eq!(actual_repl.out, "samples");
|
|
|
|
}
|