Skip to content

Commit

Permalink
Perform syntax checking with all available bashes
Browse files Browse the repository at this point in the history
 Add tests to help catch bash4-isms and ensure syntax is checked with
 all bashes on PATH in a given system.
  • Loading branch information
zbeekman committed Feb 10, 2017
1 parent b8211dc commit 390e542
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion test/acceptance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,41 @@ done <<< "$(find "${__dir}/scenario" -type f -iname 'run.sh')"

[[ "${1:-}" ]] && exit 0

# finally do some shellcheck linting
# Ensure correct syntax with all available bashes

if bashes=($(which -a bash 2> /dev/null )); then
for bash in "${bashes[@]}"; do
# shellcheck disable=SC2016
echo "==> ${bash} -n $(${bash} -c 'echo "(${BASH_VERSION})"')"
pushd "${__root}" > /dev/null

failed="false"

while IFS=$'\n' read -r file; do
[[ "${file}" =~ ^\./node_modules/ ]] && continue
[[ "${file}" =~ ^\./website/\.lanyon/ ]] && continue

echo -n " ${file}.. "

if ! "${bash}" -n "${file}" 2>> "${__accptstTmpDir}/${bash//\//.}.err"; then
echo ""
failed="true"
continue
fi

echo ""
done <<< "$(find . -type f -iname '*.sh')"

popd > /dev/null

if [[ "${failed}" = "true" ]]; then
cat "${__accptstTmpDir}/${bash//\//.}.err"
exit 1
fi
done
fi

# do some shellcheck linting
if [[ "$(command -v shellcheck)" ]]; then
echo "==> Shellcheck"
pushd "${__root}" > /dev/null
Expand Down

0 comments on commit 390e542

Please sign in to comment.