Get rid of set -e, set +e, etc. in syntax check script
This commit is contained in:
parent
11f1df42c6
commit
676198dd04
@ -1,30 +1,25 @@
|
||||
# export
|
||||
# exit 1
|
||||
# ~/check_puppet_syntax.sh
|
||||
set +x
|
||||
|
||||
set -e
|
||||
#set -u
|
||||
|
||||
fail=0
|
||||
#TODO: Run these in parallel - we have 4 cores.
|
||||
#TODO: Control the environment (through the config dir?).
|
||||
# We want to parse for all environments.
|
||||
# Is this being done, contrary to puppet report?
|
||||
#TODO: Even with --ignoreimport, some may be pulling in others,
|
||||
# meaning we're checking multiple times.
|
||||
all_files=`find -name "*.pp" -o -name "*.erb" -o -name "*.rb" -o -name "*.sh"`
|
||||
|
||||
#all_files=`find -name "*.pp" -o -name "*.erb" -o -name "*.sh" -o -name "*.rb"`
|
||||
|
||||
ruby_files=`find -type f -print0 | xargs -0 file -i | grep -i ruby | awk -F: '{ print $1 }'`
|
||||
all_files="${ruby_files} `find -name "*.pp" -o -name "*.erb" -o -name "*.sh"`"
|
||||
num_files=`echo $all_files | wc -w`
|
||||
|
||||
if test $num_files -eq "0" ; then
|
||||
echo "WARNING: no .sh, .pp, .rb or .erb files found"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Checking $num_files files for syntax errors."
|
||||
echo "Puppet version is: `puppet --version`"
|
||||
|
||||
for x in $all_files; do
|
||||
rc=0
|
||||
set +e
|
||||
case $x in
|
||||
*.pp )
|
||||
puppet-lint \
|
||||
@ -37,75 +32,48 @@ for x in $all_files; do
|
||||
--no-hard_tabs-check \
|
||||
--with-filename $x
|
||||
|
||||
rc=$?
|
||||
# Set us up to bail if we receive any syntax errors
|
||||
if test $rc -eq 0
|
||||
then
|
||||
puppet parser validate --render-as s --ignoreimport --color=false $x
|
||||
rc=$?
|
||||
fi
|
||||
puppet parser validate --render-as s --color=false $x
|
||||
;;
|
||||
*.erb | *.rb )
|
||||
erb -P -x -T '-' $x | ruby -c > /dev/null
|
||||
rc=$?
|
||||
;;
|
||||
*.sh )
|
||||
bash -n $x
|
||||
rc=$?
|
||||
;;
|
||||
esac
|
||||
# rc=$?
|
||||
set -e
|
||||
if test $rc -ne 0
|
||||
then
|
||||
fail=1
|
||||
echo "ERROR in $x (see above)"
|
||||
fi
|
||||
done
|
||||
|
||||
if test $fail -ne 0
|
||||
if [ "$1" = "-u" ];
|
||||
then
|
||||
# curl -i -u paly-ch -d '{"body":":-1: Verification FAILED: at least one file failed syntax check."}' https://api.github.com/repos/Mirantis/fuel/issues/${ghprbPullId}/comments
|
||||
echo "Verification FAILED: at least one file failed syntax check."
|
||||
exit $fail
|
||||
else
|
||||
echo "Verification SUCCEEDED."
|
||||
#echo "Verification SUCCESS: Running SPECs."
|
||||
#FIXME(mihgen): We don't run specs at the moment
|
||||
#exit 0
|
||||
if [ "$1" = "-u" ];
|
||||
then
|
||||
all_files=`find -iname "rakefile"`
|
||||
num_files=`echo $all_files | wc -w`
|
||||
if test $num_files -eq "0" ; then
|
||||
echo "WARNING: no Rakefile files found"
|
||||
exit 0
|
||||
fi
|
||||
echo "Will run $num_files RSpec tests."
|
||||
echo "Rake version is: `rake --version`"
|
||||
all_files=`find -iname "rakefile"`
|
||||
num_files=`echo $all_files | wc -w`
|
||||
if test $num_files -eq "0" ; then
|
||||
echo "WARNING: no Rakefile files found"
|
||||
exit 0
|
||||
fi
|
||||
echo "Will run $num_files RSpec tests."
|
||||
echo "Rake version is: `rake --version`"
|
||||
|
||||
for file in $all_files; do
|
||||
d=`dirname $file`
|
||||
dn=`basename $d`
|
||||
cd $d
|
||||
rc=0
|
||||
echo "RSpec-ing $dn"
|
||||
set +e
|
||||
rake spec
|
||||
rc=$?
|
||||
set -e
|
||||
if test $rc -ne 0 ; then
|
||||
fail=1
|
||||
echo "ERROR in $dn (see above)"
|
||||
fi
|
||||
cd ${WORKSPACE}
|
||||
done
|
||||
|
||||
if test $fail -ne 0 ; then
|
||||
echo "RSpec Test FAILED: at least one module failed RSpec tests."
|
||||
else
|
||||
echo "RSpec Test SUCCEEDED: All modules successfully passed RSpec tests."
|
||||
for file in $all_files; do
|
||||
d=`dirname $file`
|
||||
dn=`basename $d`
|
||||
cd $d
|
||||
rc=0
|
||||
echo "RSpec-ing $dn"
|
||||
set +e
|
||||
rake spec
|
||||
rc=$?
|
||||
set -e
|
||||
if test $rc -ne 0 ; then
|
||||
fail=1
|
||||
echo "ERROR in $dn (see above)"
|
||||
fi
|
||||
cd ${WORKSPACE}
|
||||
done
|
||||
|
||||
if test $fail -ne 0 ; then
|
||||
echo "RSpec Test FAILED: at least one module failed RSpec tests."
|
||||
else
|
||||
echo "RSpec Test SUCCEEDED: All modules successfully passed RSpec tests."
|
||||
fi
|
||||
fi
|
||||
exit $fail
|
||||
|
Loading…
Reference in New Issue
Block a user