From 49a1385543f148530f040910a09d2474df832468 Mon Sep 17 00:00:00 2001 From: Shaurya Shubham Date: Sat, 1 Feb 2020 11:42:56 +0530 Subject: [PATCH] Make tests work from directory names with spaces (#1325) --- crates/nu-test-support/src/macros.rs | 4 ++-- tests/commands/cd.rs | 2 +- tests/commands/cp.rs | 2 +- tests/commands/save.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/nu-test-support/src/macros.rs b/crates/nu-test-support/src/macros.rs index 31d24897e..f4f5f890b 100644 --- a/crates/nu-test-support/src/macros.rs +++ b/crates/nu-test-support/src/macros.rs @@ -21,7 +21,7 @@ macro_rules! nu { let commands = &*format!( " - cd {} + cd \"{}\" {} exit", $crate::fs::in_directory($cwd), @@ -103,7 +103,7 @@ macro_rules! nu_error { let commands = &*format!( " - cd {} + cd \"{}\" {} exit", $crate::fs::in_directory($cwd), diff --git a/tests/commands/cd.rs b/tests/commands/cd.rs index 24ac6eb2a..e46b8cc8b 100644 --- a/tests/commands/cd.rs +++ b/tests/commands/cd.rs @@ -24,7 +24,7 @@ fn filesystem_change_from_current_directory_using_absolute_path() { let actual = nu!( cwd: dirs.test(), r#" - cd {} + cd "{}" pwd | echo $it "#, dirs.formats() diff --git a/tests/commands/cp.rs b/tests/commands/cp.rs index 511204e35..e249b6d56 100644 --- a/tests/commands/cp.rs +++ b/tests/commands/cp.rs @@ -8,7 +8,7 @@ fn copies_a_file() { Playground::setup("cp_test_1", |dirs, _| { nu!( cwd: dirs.root(), - "cp {} cp_test_1/sample.ini", + "cp \"{}\" cp_test_1/sample.ini", dirs.formats().join("sample.ini") ); diff --git a/tests/commands/save.rs b/tests/commands/save.rs index b09cd5156..8a88f9335 100644 --- a/tests/commands/save.rs +++ b/tests/commands/save.rs @@ -37,7 +37,7 @@ fn writes_out_csv() { nu!( cwd: dirs.root(), - "open {}/cargo_sample.toml | get package | save save_test_2/cargo_sample.csv", + "open \"{}/cargo_sample.toml\" | get package | save save_test_2/cargo_sample.csv", dirs.formats() );