Skip to content

Commit

Permalink
Fix for test failures when home directory is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
aweeraman authored and krader1961 committed Nov 4, 2019
1 parent 11983a7 commit 8e4c8f0
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/cmd/ksh93/tests/builtins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,15 @@ $SHELL <<- \EOF
cd
[[ $(pwd) == "$home" ]]
EOF
[[ $? == 0 ]] || log_error 'cd with no arguments fails if HOME is unset'
if [[ $? != 0 ]]
then
if [[ -d ~$USER ]]
then
log_error 'cd with no arguments fails if HOME is unset'
else
log_warning "ignoring test of cd with no arguments if home directory does not exist"
fi
fi
cd "$TEST_DIR"
if mkdir -p f1
Expand All @@ -496,7 +504,13 @@ fi
# Regression test for https://github.com/att/ast/issues/1391
expect="$(print ~$(id -un))"
actual=$(unset HOME; $SHELL -c 'cd /; cd ~; pwd')
[[ $actual == $expect ]] || log_error "bare ~ expansion with unset HOME" "$expect" "$actual"
# If the home directory for the user doesn't exist, then skip test
if [[ ! -d $expect ]]
then
log_warning "skipping test of bare ~ expansion when home directory does not exist: $expect"
else
[[ $actual == $expect ]] || log_error "bare ~ expansion with unset HOME" "$expect" "$actual"
fi
# =======
TESTDIRSYMLINK="$TEST_DIR/testdirsymlink"
Expand Down

0 comments on commit 8e4c8f0

Please sign in to comment.