mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 06:30:08 +02:00
Make g -
switch to the last used shell (#6249)
* Make `g -` switch to the last used shell Related #6223 Signed-off-by: nibon7 <nibon7@163.com> * simplify error handling Signed-off-by: nibon7 <nibon7@163.com> * update NUSHELL_LAST_SHELL environment Signed-off-by: nibon7 <nibon7@163.com> * add test Signed-off-by: nibon7 <nibon7@163.com> * fix description Signed-off-by: nibon7 <nibon7@163.com>
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
use nu_test_support::{nu, pipeline, playground::Playground};
|
||||
|
||||
#[test]
|
||||
fn list_shells() {
|
||||
@ -29,3 +29,63 @@ fn enter_not_exist_shell() {
|
||||
|
||||
assert!(actual.err.contains("Not found"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn switch_to_last_used_shell_1() {
|
||||
Playground::setup("switch_last_used_shell_1", |dirs, sandbox| {
|
||||
sandbox.mkdir("foo").mkdir("bar");
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
pipeline(
|
||||
r#"enter foo; enter ../bar; g 0; g -;g | get active.2"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn switch_to_last_used_shell_2() {
|
||||
Playground::setup("switch_last_used_shell_2", |dirs, sandbox| {
|
||||
sandbox.mkdir("foo").mkdir("bar");
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
pipeline(
|
||||
r#"enter foo; enter ../bar; n; g -;g | get active.2"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn switch_to_last_used_shell_3() {
|
||||
Playground::setup("switch_last_used_shell_3", |dirs, sandbox| {
|
||||
sandbox.mkdir("foo").mkdir("bar");
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
pipeline(
|
||||
r#"enter foo; enter ../bar; p; g -;g | get active.2"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn switch_to_last_used_shell_4() {
|
||||
Playground::setup("switch_last_used_shell_4", |dirs, sandbox| {
|
||||
sandbox.mkdir("foo").mkdir("bar");
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
pipeline(
|
||||
r#"enter foo; enter ../bar; g 2; exit; g -;g | get active.0"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user