Enable the use of multiple dots in FS Shell commands (#1547)

Every dot after `..` means another parent directory.
This commit is contained in:
Kevin Del Castillo
2020-04-06 06:28:56 -05:00
committed by GitHub
parent c4daa2e40f
commit d0618b0b32
7 changed files with 256 additions and 56 deletions

View File

@@ -85,9 +85,26 @@ fn filesystem_change_current_directory_to_parent_directory() {
})
}
#[test]
fn filesystem_change_current_directory_to_two_parents_up_using_multiple_dots() {
Playground::setup("cd_test_6", |dirs, sandbox| {
sandbox.within("foo").mkdir("bar");
let actual = nu!(
cwd: dirs.test().join("foo/bar"),
r#"
cd ...
pwd | echo $it
"#
);
assert_eq!(PathBuf::from(actual), *dirs.test());
})
}
#[test]
fn filesystem_change_current_directory_to_parent_directory_after_delete_cwd() {
Playground::setup("cd_test_5_1", |dirs, sandbox| {
Playground::setup("cd_test_7", |dirs, sandbox| {
sandbox.within("foo").mkdir("bar");
let actual = nu!(
@@ -109,7 +126,7 @@ fn filesystem_change_current_directory_to_parent_directory_after_delete_cwd() {
#[test]
fn filesystem_change_to_home_directory() {
Playground::setup("cd_test_6", |dirs, _| {
Playground::setup("cd_test_8", |dirs, _| {
let actual = nu!(
cwd: dirs.test(),
r#"
@@ -124,7 +141,7 @@ fn filesystem_change_to_home_directory() {
#[test]
fn filesystem_change_to_a_directory_containing_spaces() {
Playground::setup("cd_test_7", |dirs, sandbox| {
Playground::setup("cd_test_9", |dirs, sandbox| {
sandbox.mkdir("robalino turner katz");
let actual = nu!(
@@ -144,7 +161,7 @@ fn filesystem_change_to_a_directory_containing_spaces() {
#[test]
fn filesystem_not_a_directory() {
Playground::setup("cd_test_8", |dirs, sandbox| {
Playground::setup("cd_test_10", |dirs, sandbox| {
sandbox.with_files(vec![EmptyFile("ferris_did_it.txt")]);
let actual = nu_error!(
@@ -178,7 +195,7 @@ fn filesystem_directory_not_found() {
#[test]
fn valuesystem_change_from_current_path_using_relative_path() {
Playground::setup("cd_test_9", |dirs, sandbox| {
Playground::setup("cd_test_11", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContent(
"sample.toml",
r#"
@@ -209,7 +226,7 @@ fn valuesystem_change_from_current_path_using_relative_path() {
#[test]
fn valuesystem_change_from_current_path_using_absolute_path() {
Playground::setup("cd_test_10", |dirs, sandbox| {
Playground::setup("cd_test_12", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContent(
"sample.toml",
r#"
@@ -243,7 +260,7 @@ fn valuesystem_change_from_current_path_using_absolute_path() {
#[test]
fn valuesystem_switch_back_to_previous_working_path() {
Playground::setup("cd_test_11", |dirs, sandbox| {
Playground::setup("cd_test_13", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContent(
"sample.toml",
r#"
@@ -279,7 +296,7 @@ fn valuesystem_switch_back_to_previous_working_path() {
#[test]
fn valuesystem_change_from_current_path_using_relative_path_and_dash() {
Playground::setup("cd_test_12", |dirs, sandbox| {
Playground::setup("cd_test_14", |dirs, sandbox| {
sandbox
.with_files(vec![FileWithContent(
"sample.toml",
@@ -313,7 +330,7 @@ fn valuesystem_change_from_current_path_using_relative_path_and_dash() {
#[test]
fn valuesystem_change_current_path_to_parent_path() {
Playground::setup("cd_test_13", |dirs, sandbox| {
Playground::setup("cd_test_15", |dirs, sandbox| {
sandbox
.with_files(vec![FileWithContent(
"sample.toml",
@@ -340,7 +357,7 @@ fn valuesystem_change_current_path_to_parent_path() {
#[test]
fn valuesystem_change_to_a_path_containing_spaces() {
Playground::setup("cd_test_15", |dirs, sandbox| {
Playground::setup("cd_test_17", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContent(
"sample.toml",
r#"