Skip to content

Commit

Permalink
Stop local override of $path variable
Browse files Browse the repository at this point in the history
Fixes #5
  • Loading branch information
molovo committed Dec 21, 2016
1 parent 977f35b commit c239ac7
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions zunit
Original file line number Diff line number Diff line change
Expand Up @@ -140,84 +140,84 @@ function _zunit_assert_not_in() {
# Assert the a path exists
###
function _zunit_assert_exists() {
local path=$1 filepath
local pathname=$1 filepath

# If filepath is relative, prepend the test directory
if [[ "${path:0:1}" != "/" ]]; then
filepath="$testdir/${path}"
if [[ "${pathname:0:1}" != "/" ]]; then
filepath="$testdir/${pathname}"
fi

[[ -e $filepath ]] && return 0

echo "'$path' does not exist"
echo "'$pathname' does not exist"
exit 1
}

###
# Assert the a path exists and is a file
###
function _zunit_assert_is_file() {
local path=$1 filepath
local pathname=$1 filepath

# If filepath is relative, prepend the test directory
if [[ "${path:0:1}" != "/" ]]; then
filepath="$testdir/${path}"
if [[ "${pathname:0:1}" != "/" ]]; then
filepath="$testdir/${pathname}"
fi

[[ -f $filepath ]] && return 0

echo "'$path' does not exist or is not a file"
echo "'$pathname' does not exist or is not a file"
exit 1
}

###
# Assert the a path exists and is a directory
###
function _zunit_assert_is_dir() {
local path=$1 filepath
local pathname=$1 filepath

# If filepath is relative, prepend the test directory
if [[ "${path:0:1}" != "/" ]]; then
filepath="$testdir/${path}"
if [[ "${pathname:0:1}" != "/" ]]; then
filepath="$testdir/${pathname}"
fi

[[ -d $filepath ]] && return 0

echo "'$path' does not exist or is not a directory"
echo "'$pathname' does not exist or is not a directory"
exit 1
}

###
# Assert the a path exists and is a symbolic link
###
function _zunit_assert_is_link() {
local path=$1 filepath
local pathname=$1 filepath

# If filepath is relative, prepend the test directory
if [[ "${path:0:1}" != "/" ]]; then
filepath="$testdir/${path}"
if [[ "${pathname:0:1}" != "/" ]]; then
filepath="$testdir/${pathname}"
fi

[[ -h $filepath ]] && return 0

echo "'$path' does not exist or is not a symbolic link"
echo "'$pathname' does not exist or is not a symbolic link"
exit 1
}

###
# Assert the a path exists and is readable
###
function _zunit_assert_is_readable() {
local path=$1 filepath
local pathname=$1 filepath

# If filepath is relative, prepend the test directory
if [[ "${path:0:1}" != "/" ]]; then
filepath="$testdir/${path}"
if [[ "${pathname:0:1}" != "/" ]]; then
filepath="$testdir/${pathname}"
fi

[[ -r $filepath ]] && return 0

echo "'$path' does not exist or is not readable"
echo "'$pathname' does not exist or is not readable"
exit 1
}

Expand Down

0 comments on commit c239ac7

Please sign in to comment.