Skip to content

Commit

Permalink
tests: add a check to prevent bashisms from creeping into code
Browse files Browse the repository at this point in the history
  • Loading branch information
austin987 committed Sep 28, 2016
1 parent 94d899e commit 5e76519
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ check:
echo 'To suppress tests in debuild, export DEB_BUILD_OPTIONS=nocheck'
echo ''
echo 'FIXME: this should kill stray wine processes before and after, but some leak through, you might need to kill them.'
# Check for shellscript issues first:
echo "Running checkbashisms:"
sh ./tests/prevent-bashims || exit 1
# Check all script dependencies before starting tests:
echo "Checking dependencies.."
sh ./src/linkcheck.sh check-deps || exit 1
Expand Down Expand Up @@ -103,6 +106,9 @@ test:
echo 'To suppress tests in debuild, export DEB_BUILD_OPTIONS=nocheck'
echo ''
echo 'FIXME: this should kill stray wine processes before and after, but some leak through, you might need to kill them.'
# Check for shellscript issues first:
echo "Running checkbashisms:"
sh ./tests/prevent-bashims || exit 1
# Check all script dependencies before starting tests:
echo "Checking dependencies.."
sh ./src/linkcheck.sh check-deps || exit 1
Expand Down
21 changes: 21 additions & 0 deletions tests/prevent-bashims
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

set -x
set -e

# Copyright 2016 Austin English
# LPGL 2.1+

# Wrapper around checkbashisms
# May also add other checks in future, like shellcheck

if [ ! command -v checkbashisms > /dev/null 2>&1 ] ; then
echo "checkbashisms must be installed!"
fi

for shellscript in \
$(find . -type f -not -path "./.git/*" -exec file {} \; | grep -e 'POSIX shell script' | cut -d : -f1)
do
echo "Checking ${shellscript}:"
checkbashisms ${shellscript} || exit 1
done

0 comments on commit 5e76519

Please sign in to comment.