datatracker/test/show-mods

61 lines
2 KiB
Bash
Executable file

#!/bin/bash
# Since it's a pain to manually update the acceptable diffs, this script will pick
# new and modified diffs from the buildbot results, massage them slightly, display
# the difference between the old and new (or the new if no old one) and ask
# whether the diff should be updated.
#
# This script assumes that buildbot log files are available in $bblogdir; this
# will be true only on the buildbot master.
program=${0##*/}
progdir=${0%/*}
bblogdir=/var/lib/buildbot/master/ietfdb/builder1
diffdir=$progdir/diff
function die() { echo "$program: $*"; echo "Terminating"; exit 1; }
sudo chown buildbot:staff -R $bblogdir
sudo chmod g+rw -R $bblogdir
latest=$(ls $bblogdir | egrep "^[0-9]+$" | sort -nr | head -n 1)
modprefix="$bblogdir/$latest-log-django-test-mod_"
if ls $modprefix* > /dev/null; then
for mod in $modprefix*; do
diff="$diffdir/${mod#$modprefix}"
[ -f $diff ] || echo "Missing diff-file: $diff"
temp="/tmp/${mod##*/}"
tail -n +3 $mod | head -n -1 | tr -d "\r" > $temp
echo "========================================================================"
echo " ${diff##*/}"
echo "------------------------------------------------------------------------"
if diff $diff $temp | grep -v "\ No newline at end of file"; then
echo ""
read -p "Update diff [y/N]?" update
if [ "$update" = "Y" -o "$update" = "y" -o "$update" = "yes" ]; then cp $temp $diff; fi
fi
rm $temp
done
fi
modprefix="$bblogdir/$latest-log-django-test-diff_"
if ls $modprefix* > /dev/null; then
for mod in $modprefix*; do
diff="$diffdir/${mod#$modprefix}"
[ -f $diff ] && die "Diff-file $diff exists when it shouldn't..."
temp="/tmp/${mod##*/}"
tail -n +3 $mod | head -n -1 | tr -d "\r" > $temp
echo "========================================================================"
echo " ${diff##*/}"
echo "------------------------------------------------------------------------"
cat $temp
echo ""
read -p "Create diff [y/N]?" update
if [ "$update" = "Y" -o "$update" = "y" -o "$update" = "yes" ]; then cp $temp $diff; fi
rm $temp
done
fi