Skip to content

Commit 560fbb9

Browse files
committed
make tests work on mac
1 parent 66ad83c commit 560fbb9

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

crates/nu-utils/standard_library/test_dirs.nu

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,40 @@ def clean [path: path] {
99

1010
export def test_dirs_command [] {
1111
# need some directories to play with
12-
let base_path = (($nu.temp-path) | path join $"test_dirs_(random uuid)" | path expand )
13-
let path_a = ($base_path | path expand | path join "a")
14-
let path_b = ($base_path | path expand | path join "b")
12+
let base_path = ($nu.temp-path | path join $"test_dirs_(random uuid)")
13+
let path_a = ($base_path | path join "a")
14+
let path_b = ($base_path | path join "b")
1515

1616
try {
17-
mkdir ($base_path | path expand) $path_a $path_b
18-
cd ($base_path | path expand)
17+
mkdir $base_path $path_a $path_b
18+
# Now that we've created the directories, we need to expand them to include symlinks
19+
let base_path = ($base_path | path expand)
20+
let path_a = ($path_a | path expand)
21+
let path_b = ($path_b | path expand)
22+
23+
cd $base_path
1924
use std.nu "dirs next"
2025
use std.nu "dirs prev"
2126
use std.nu "dirs add"
2227
use std.nu "dirs drop"
2328
use std.nu "dirs show"
2429

2530
assert length $env.DIRS_LIST 1 "list is just pwd after initialization"
26-
assert equal ($base_path | path expand) $env.DIRS_LIST.0 "list is just pwd after initialization"
31+
assert equal $base_path $env.DIRS_LIST.0 "list is just pwd after initialization"
2732

2833
dirs next
29-
assert equal ($base_path | path expand) $env.DIRS_LIST.0 "next wraps at end of list"
34+
assert equal $base_path $env.DIRS_LIST.0 "next wraps at end of list"
3035

3136
dirs prev
32-
assert equal ($base_path | path expand) $env.DIRS_LIST.0 "prev wraps at top of list"
37+
assert equal $base_path $env.DIRS_LIST.0 "prev wraps at top of list"
3338

3439
dirs add $path_b $path_a
3540
assert equal $path_b $env.PWD "add changes PWD to first added dir"
3641
assert length $env.DIRS_LIST 3 "add in fact adds to list"
3742
assert equal $path_a $env.DIRS_LIST.2 "add in fact adds to list"
3843

3944
dirs next 2
40-
assert equal ($base_path | path expand) $env.PWD "next wraps at end of list"
45+
assert equal $base_path $env.PWD "next wraps at end of list"
4146

4247
dirs prev 1
4348
assert equal $path_a $env.PWD "prev wraps at start of list"
@@ -46,9 +51,9 @@ export def test_dirs_command [] {
4651
assert length $env.DIRS_LIST 2 "drop removes from list"
4752
assert equal ($base_path | path expand) $env.PWD "drop changes PWD to next in list (after dropped element)"
4853

49-
assert equal (dirs show) [[active path]; [true ($base_path | path expand)] [false $path_b]] "show table contains expected information"
54+
assert equal (dirs show) [[active path]; [true $base_path] [false $path_b]] "show table contains expected information"
5055
} catch { |error|
51-
clean ($base_path | path expand)
56+
clean $base_path
5257

5358
let error = (
5459
$error
@@ -69,5 +74,5 @@ export def test_dirs_command [] {
6974
}
7075
}
7176

72-
try { clean ($base_path | path expand) }
77+
try { clean $base_path }
7378
}

0 commit comments

Comments
 (0)