cfg/runtests.sh: Check syntax of defines in configuration files. (#1303)

travis: Add xmlstarlet package used by cfg/runtests.sh
This commit is contained in:
Sebastian 2018-07-12 08:40:26 +02:00 committed by GitHub
parent 086a005a9f
commit 5cc8da2db4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -39,7 +39,7 @@ matrix:
before_install:
# install needed deps
- sudo apt-get update -qq
- sudo apt-get install -qq python-pygments qt5-default qt5-qmake qtbase5-dev qtcreator libxml2-utils libpcre3 gdb unzip wx-common
- sudo apt-get install -qq python-pygments qt5-default qt5-qmake qtbase5-dev qtcreator libxml2-utils libpcre3 gdb unzip wx-common xmlstarlet
script:
# fail the entire job as soon as one of the subcommands exits non-zero to save time and resources

View File

@ -100,3 +100,25 @@ else
fi
fi
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=gtk -f ${DIR}gtk.c
# Check the syntax of the defines in the configuration files
set +e
xmlstarlet --version
XMLSTARLET_RETURNCODE=$?
set -e
if [ $XMLSTARLET_RETURNCODE -ne 0 ]; then
echo "xmlstarlet needed to extract defines, skipping defines check."
else
for configfile in cfg/*.cfg; do
echo "Checking defines in $configfile"
# Disable debugging output temporarily since there could be many defines
set +x
# XMLStarlet returns 1 if no elements were found which is no problem here
set +e
EXTRACTED_DEFINES=$(xmlstarlet sel -t -m '//define' -c . -n <$configfile)
set -e
EXTRACTED_DEFINES=$(echo "$EXTRACTED_DEFINES" | sed 's/<define name="/#define /g' | sed 's/" value="/ /g' | sed 's/"\/>//g')
echo "$EXTRACTED_DEFINES" | gcc -fsyntax-only -xc -Werror -
set -x
done
fi