Add a new passfailtest.

This tests that the target file isn't removed or changed if building fails.
This commit is contained in:
Avery Pennarun 2010-11-21 06:12:27 -08:00
commit e8584c8d76
4 changed files with 36 additions and 1 deletions

28
t/passfailtest.do Normal file
View file

@ -0,0 +1,28 @@
rm -f pleasefail
redo passfail
if [ ! -e passfail ]; then
echo "passfail should exist" >&2
exit 42
fi
PF1=$(cat passfail)
touch pleasefail
if redo passfail 2>/dev/null; then
echo "redo passfail should have failed" >&2
exit 42
fi
if [ ! -e passfail ]; then
echo "passfail should STILL exist" >&2
exit 42
fi
PF2=$(cat passfail)
if [ "$PF1" != "$PF2" ]; then
echo "passfail changed even though it failed" >&2
exit 42
fi
rm -f pleasefail
redo passfail || exit 43
PF3=$(cat passfail)
if [ "$PF1" = "$PF3" ]; then
echo "passfail did not change even though it passed" >&2
exit 42
fi