-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
proc setup {home user} { | ||
upvar $home _home | ||
upvar $user _user | ||
save_env | ||
assert_bash_exec {echo "$HOME"} {} /@ _home | ||
set _home [string trim $_home] | ||
assert_bash_exec {echo "$USER"} {} /@ _user | ||
set _user [string trim $_user] | ||
} | ||
|
||
proc teardown {} { | ||
assert_env_unmodified { | ||
/COMPREPLY=/d | ||
/cur=/d | ||
} | ||
} | ||
|
||
|
||
setup home user | ||
|
||
|
||
set test "function should run without errors" | ||
assert_bash_exec {_expand > /dev/null} $test | ||
sync_after_int | ||
|
||
|
||
set test "function should not pollute environment" | ||
# NOTE: A possible environment pollution is detected by assert_env_modified() in teardown() | ||
assert_bash_exec {foo() { _expand; }; foo; unset foo} $test | ||
sync_after_int | ||
|
||
|
||
set test "~$user should set $home to COMPREPLY" | ||
set cmd [format {cur="~%s" ; _expand ; printf "%%s\n" "$COMPREPLY"} $user] | ||
assert_bash_list "$home" $cmd $test | ||
sync_after_int | ||
|
||
|
||
set test "~$user/a should set $home/a to cur" | ||
set cmd [format {cur="~%s/a" ; _expand ; printf "%%s\n" "$cur"} $user] | ||
assert_bash_list "$home/a" $cmd $test | ||
sync_after_int | ||
|
||
|
||
teardown |