Skip to content

Commit 984646c

Browse files
author
David Wahlstrom
committed
only run rspec if spec dir exists
1 parent 1c057d7 commit 984646c

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

commit_hooks/rspec_puppet_checks.sh

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,22 @@ changedmodules=$(echo -e "$tmpchangedmodules" | sort -u)
2020

2121
#now that we have the list of modules that changed, run rspec for each module
2222
for module_dir in $changedmodules; do
23-
echo -e "\e[0;36mRunning rspec-puppet tests for module $1...\e[0m"
24-
cd $module_dir
25-
#this will run rspec for every test in the module
26-
rspec > $error_msg
27-
RC=$?
28-
if [ $RC -ne 0 ]; then
29-
echo -en "\e[0;31m"
30-
cat $error_msg
31-
echo -e "Error: rspec-puppet test(s) failed for $module_dir (see above)\e[0m"
32-
syntax_errors=`expr $syntax_errors + 1`
23+
#only run rspec if the "spec" directory exists
24+
if [ -d "${module_dir}/spec" ]; then
25+
echo -e "\e[0;36mRunning rspec-puppet tests for module $1...\e[0m"
26+
cd $module_dir
27+
#this will run rspec for every test in the module
28+
rspec > $error_msg
29+
RC=$?
30+
if [ $RC -ne 0 ]; then
31+
echo -en "\e[0;31m"
32+
cat $error_msg
33+
echo -e "Error: rspec-puppet test(s) failed for $module_dir (see above)\e[0m"
34+
syntax_errors=`expr $syntax_errors + 1`
35+
fi
3336
fi
3437
done
38+
3539
cd $oldpwd > /dev/null
3640

3741
rm $error_msg

0 commit comments

Comments
 (0)