mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 14:03:58 +00:00
parent
aaeb7d107c
commit
3c2cf6241b
1 changed files with 63 additions and 0 deletions
|
@ -126,10 +126,73 @@ test $PWD = $base/-testdir
|
|||
echo $status
|
||||
#CHECK: 0
|
||||
|
||||
# test a few error cases - nonexistent directory
|
||||
set -l old_cdpath $CDPATH
|
||||
set -l old_path $PWD
|
||||
cd nonexistent
|
||||
#CHECKERR: cd: The directory 'nonexistent' does not exist
|
||||
#CHECKERR: {{.*}}/cd.fish (line {{\d+}}):
|
||||
#CHECKERR: builtin cd $argv
|
||||
#CHECKERR: ^
|
||||
#CHECKERR: in function 'cd' with arguments 'nonexistent'
|
||||
#CHECKERR: called on line {{\d+}} of file {{.*}}/cd.fish
|
||||
|
||||
touch file
|
||||
cd file
|
||||
#CHECKERR: cd: 'file' is not a directory
|
||||
#CHECKERR: {{.*}}/cd.fish (line {{\d+}}):
|
||||
#CHECKERR: builtin cd $argv
|
||||
#CHECKERR: ^
|
||||
#CHECKERR: in function 'cd' with arguments 'file'
|
||||
#CHECKERR: called on line {{\d+}} of file {{.*}}/cd.fish
|
||||
|
||||
# a directory that isn't executable
|
||||
mkdir bad-perms
|
||||
chmod -x bad-perms
|
||||
cd bad-perms
|
||||
#CHECKERR: cd: Permission denied: 'bad-perms'
|
||||
#CHECKERR: {{.*}}/cd.fish (line {{\d+}}):
|
||||
#CHECKERR: builtin cd $argv
|
||||
#CHECKERR: ^
|
||||
#CHECKERR: in function 'cd' with arguments 'bad-perms'
|
||||
#CHECKERR: called on line {{\d+}} of file {{.*}}/cd.fish
|
||||
|
||||
cd $old_path
|
||||
mkdir -p cdpath-dir/bad-perms
|
||||
mkdir -p cdpath-dir/nonexistent
|
||||
mkdir -p cdpath-dir/file
|
||||
set CDPATH $PWD/cdpath-dir $old_cdpath
|
||||
|
||||
# A different directory with the same name that is first in $CDPATH works.
|
||||
cd bad-perms
|
||||
cd $old_path
|
||||
cd nonexistent
|
||||
cd $old_path
|
||||
cd file
|
||||
cd $old_path
|
||||
|
||||
# Even if the good dirs are later in $CDPATH most errors still aren't a problem
|
||||
# - they just cause us to keep looking.
|
||||
cd $old_path
|
||||
set CDPATH $old_cdpath $PWD/cdpath-dir
|
||||
cd nonexistent
|
||||
cd $old_path
|
||||
cd bad-perms
|
||||
# Permission errors are still a problem!
|
||||
#CHECKERR: cd: Permission denied: 'bad-perms'
|
||||
#CHECKERR: {{.*}}/cd.fish (line {{\d+}}):
|
||||
#CHECKERR: builtin cd $argv
|
||||
#CHECKERR: ^
|
||||
#CHECKERR: in function 'cd' with arguments 'bad-perms'
|
||||
#CHECKERR: called on line {{\d+}} of file {{.*}}/cd.fish
|
||||
cd $old_path
|
||||
cd file
|
||||
cd $old_path
|
||||
|
||||
# cd back before removing the test directory again.
|
||||
cd $oldpwd
|
||||
rm -Rf $base
|
||||
set -g CDPATH ./
|
||||
|
||||
# Verify that PWD on-variable events are sent
|
||||
function __fish_test_changed_pwd --on-variable PWD
|
||||
|
|
Loading…
Reference in a new issue