Permalink
Browse files

Set SHPEC_ROOT without using find

  • Loading branch information...
1 parent 9d64313 commit f5b48d76bc6e296296c4c1e636900d4c30324254 @locochris locochris committed Mar 6, 2013
Showing with 12 additions and 13 deletions.
  1. +1 −1 CHANGELOG.md
  2. +3 −4 bin/shpec
  3. +8 −8 shpec/shpec_shpec.sh
View
2 CHANGELOG.md
@@ -2,7 +2,7 @@
## 0.0.9 Unreleased
- *
+ * Set SHPEC_ROOT without using find
## 0.0.8 (Mar 6 2013)
View
7 bin/shpec
@@ -96,8 +96,7 @@ print_result() {
fi
}
-shpec_root=${SHPEC_ROOT:-$(find . -name 'shpec' -type d | grep -v '.git')}
-shpec_root=${shpec_root:-.} # default to current directory
+SHPEC_ROOT=${SHPEC_ROOT:-$([[ -d './shpec' ]] && echo './shpec' || echo '.')}
case "$1" in
@@ -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
. "$matcher_file"
done
- files="${@:-$(find "$shpec_root" -name '*_shpec.sh')}"
+ files="${@:-$(find $SHPEC_ROOT -name '*_shpec.sh')}"
time for file in $files; do
. "$file"
View
16 shpec/shpec_shpec.sh
@@ -79,37 +79,37 @@ line'
end_describe
describe "exit codes"
- shpec_cmd="$shpec_root/../bin/shpec"
+ shpec_cmd="$SHPEC_ROOT/../bin/shpec"
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"
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"
end_describe
describe "output"
it "outputs passing tests to STDOUT"
- message="$(. $shpec_root/etc/passing_example)"
+ message="$(. $SHPEC_ROOT/etc/passing_example)"
assert match "$message" "a\ passing\ test"
it "outputs failing tests to STDOUT"
- message="$(. $shpec_root/etc/failing_example)"
+ message="$(. $SHPEC_ROOT/etc/failing_example)"
assert match "$message" "a\ failing\ test"
end_describe
describe "commandline options"
- shpec_cmd="$shpec_root/../bin/shpec"
+ shpec_cmd="$SHPEC_ROOT/../bin/shpec"
describe "--version"
it "outputs the current version number"
message="$($shpec_cmd --version)"
- assert match "$message" "$(cat $shpec_root/../VERSION)"
+ assert match "$message" "$(cat $SHPEC_ROOT/../VERSION)"
end_describe
describe "-v"
it "outputs the current version number"
message="$($shpec_cmd -v)"
- assert match "$message" "$(cat $shpec_root/../VERSION)"
+ assert match "$message" "$(cat $SHPEC_ROOT/../VERSION)"
end_describe
end_describe
end_describe

0 comments on commit f5b48d7

Please sign in to comment.