Created
April 6, 2018 02:31
-
-
Save whot/0fa8e0ab40e294b4dbf9d62de97d7794 to your computer and use it in GitHub Desktop.
run-test.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Script that runs sudo make check and on success adds a git note, if | |
# possible. | |
# | |
# If $CWD isn't a git directory or there are local changes, no note is | |
# added. | |
# If tellme/espeak is available, it is used to notify the user about | |
# required passwords | |
# | |
PKG_CONFIG_PATH=/opt/xorg/lib/pkgconfig | |
LD_LIBRARY_PATH=/opt/xorg/lib/ | |
rc=1 | |
sha="" | |
tellme= | |
festival="`which espeak 2>/dev/null` --stdin" | |
date=`date` | |
status="FAIL" | |
set -u | |
run_make() { | |
$tellme make | |
if [ -n "$festival" ]; then | |
/usr/bin/sudo -n true 2>/dev/null || echo "password required" | $festival | |
fi | |
$tellme sudo make check -j 8 | |
rc=$? | |
if [ $? -eq 0 ]; then | |
status="SUCCESS" | |
else | |
status="FAIL" | |
fi | |
} | |
run_meson() { | |
builddir="test-build" | |
rm -rf "$builddir" | |
meson "$builddir" | |
$tellme ninja -C "$builddir" | |
$tellme sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH PKG_CONFIG_PATH=$PKG_CONFIG_PATH ninja -C "$builddir" test | |
rc=$? | |
if [ $rc -ne 0 ]; then | |
return | |
fi | |
pushd "$builddir" | |
$tellme sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH PKG_CONFIG_PATH=$PKG_CONFIG_PATH meson test --setup=valgrind | |
rc=$? | |
if [ $rc -eq 0 ]; then | |
status="SUCCESS" | |
else | |
status="FAIL" | |
fi | |
popd | |
} | |
git rev-list --max-count=1 HEAD > /dev/null 2>&1 | |
if [ $? -ne 0 ]; then | |
echo "Not a git repository, skipping git-notes entry" | |
else | |
git diff --exit-code -s | |
if [ $? -eq 0 ]; then | |
sha=`git rev-list --max-count=1 HEAD` | |
else | |
echo "******** Local changes present, skipping git notes entry *********" | |
fi | |
fi | |
t1=`date -u +'%s'` | |
if [ -f "meson.build" ]; then | |
run_meson | |
elif [ -f "Makefile" ]; then | |
run_make | |
else | |
echo "cannot find meson.build or makefile" | |
exit 1 | |
fi | |
t2=`date -u +'%s'` | |
tdelta=$(($t2 - $t1)) | |
if [ -n "$sha" ]; then | |
git notes --ref "test-$HOSTNAME" append -m "$status: $HOSTNAME: make check $date (${tdelta}s)" $sha | |
fi | |
exit $rc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment