Autoenv fix: Exitscripts incorrectly running when visiting a subdirectory (#2326)

* Add test case for issue

* Preliminary fix

* fmt

* Reorder asserts

* move insertion

* Touch nu-env.toml

* Cleanup

* touch nu-env toml

* Remove touch

* Change feature flags
This commit is contained in:
Sam Hedin
2020-08-11 21:54:49 +02:00
committed by GitHub
parent 43e9c89125
commit 3c18169f63
2 changed files with 21 additions and 19 deletions

View File

@ -38,9 +38,11 @@ fn takes_rows_of_nu_value_strings_and_pipes_it_to_stdin_of_external() {
})
}
#[cfg(feature = "which")]
#[cfg(feature = "directories-support")]
#[cfg(feature = "which-support")]
#[test]
fn autoenv() {
use nu_test_support::fs::Stub::FileWithContent;
Playground::setup("autoenv_test", |dirs, sandbox| {
sandbox.mkdir("foo/bar");
sandbox.mkdir("bizz/buzz");
@ -105,6 +107,15 @@ fn autoenv() {
);
assert!(actual.out.contains("hello.txt"));
// If inside a directory with exitscripts, entering a subdirectory should not trigger the exitscripts.
let actual = nu!(
cwd: dirs.test(),
r#"autoenv trust
cd foob
ls | where name == "bye.txt" | get name"#
);
assert!(!actual.out.contains("bye.txt"));
// Make sure entry scripts are run when re-visiting a directory
let actual = nu!(
cwd: dirs.test(),