Skip to content

Commit

Permalink
Set SHPEC_ROOT without using find
Browse files Browse the repository at this point in the history
  • Loading branch information
chris committed Mar 6, 2013
1 parent 9d64313 commit f5b48d7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -2,7 +2,7 @@


## 0.0.9 Unreleased ## 0.0.9 Unreleased


* * Set SHPEC_ROOT without using find


## 0.0.8 (Mar 6 2013) ## 0.0.8 (Mar 6 2013)


Expand Down
7 changes: 3 additions & 4 deletions bin/shpec
Expand Up @@ -96,8 +96,7 @@ print_result() {
fi fi
} }


shpec_root=${SHPEC_ROOT:-$(find . -name 'shpec' -type d | grep -v '.git')} SHPEC_ROOT=${SHPEC_ROOT:-$([[ -d './shpec' ]] && echo './shpec' || echo '.')}
shpec_root=${shpec_root:-.} # default to current directory


case "$1" in case "$1" in


Expand All @@ -107,13 +106,13 @@ case "$1" in


* ) * )


matcher_files="$(find "$shpec_root/matchers" -name '*.sh' 2>/dev/null)" matcher_files="$(find "$SHPEC_ROOT/matchers" -name '*.sh' 2>/dev/null)"


for matcher_file in $matcher_files; do for matcher_file in $matcher_files; do
. "$matcher_file" . "$matcher_file"
done done


files="${@:-$(find "$shpec_root" -name '*_shpec.sh')}" files="${@:-$(find $SHPEC_ROOT -name '*_shpec.sh')}"


time for file in $files; do time for file in $files; do
. "$file" . "$file"
Expand Down
16 changes: 8 additions & 8 deletions shpec/shpec_shpec.sh
Expand Up @@ -79,37 +79,37 @@ line'
end_describe end_describe


describe "exit codes" describe "exit codes"
shpec_cmd="$shpec_root/../bin/shpec" shpec_cmd="$SHPEC_ROOT/../bin/shpec"
it "returns nonzero if any test fails" it "returns nonzero if any test fails"
$shpec_cmd $shpec_root/etc/failing_example &> /dev/null $shpec_cmd $SHPEC_ROOT/etc/failing_example &> /dev/null
assert unequal "$?" "0" assert unequal "$?" "0"


it "returns zero if a suite passes" it "returns zero if a suite passes"
$shpec_cmd $shpec_root/etc/passing_example &> /dev/null $shpec_cmd $SHPEC_ROOT/etc/passing_example &> /dev/null
assert equal "$?" "0" assert equal "$?" "0"
end_describe end_describe


describe "output" describe "output"
it "outputs passing tests to STDOUT" it "outputs passing tests to STDOUT"
message="$(. $shpec_root/etc/passing_example)" message="$(. $SHPEC_ROOT/etc/passing_example)"
assert match "$message" "a\ passing\ test" assert match "$message" "a\ passing\ test"


it "outputs failing tests to STDOUT" it "outputs failing tests to STDOUT"
message="$(. $shpec_root/etc/failing_example)" message="$(. $SHPEC_ROOT/etc/failing_example)"
assert match "$message" "a\ failing\ test" assert match "$message" "a\ failing\ test"
end_describe end_describe


describe "commandline options" describe "commandline options"
shpec_cmd="$shpec_root/../bin/shpec" shpec_cmd="$SHPEC_ROOT/../bin/shpec"
describe "--version" describe "--version"
it "outputs the current version number" it "outputs the current version number"
message="$($shpec_cmd --version)" message="$($shpec_cmd --version)"
assert match "$message" "$(cat $shpec_root/../VERSION)" assert match "$message" "$(cat $SHPEC_ROOT/../VERSION)"
end_describe end_describe
describe "-v" describe "-v"
it "outputs the current version number" it "outputs the current version number"
message="$($shpec_cmd -v)" message="$($shpec_cmd -v)"
assert match "$message" "$(cat $shpec_root/../VERSION)" assert match "$message" "$(cat $SHPEC_ROOT/../VERSION)"
end_describe end_describe
end_describe end_describe
end_describe end_describe

0 comments on commit f5b48d7

Please sign in to comment.