Fix tests when the sqlite3 command line utility isn't installed.

We know the user already has to have python, so use its bindings.
This commit is contained in:
Joseph Garvin 2011-02-22 22:47:00 -06:00 committed by Avery Pennarun
commit d039aad57b
12 changed files with 50 additions and 41 deletions

View file

@ -5,21 +5,21 @@ redo t/always1
cd t
[ "$(wc -l <always1.log)" -eq 1 ] || exit 11
# This shouldn't rebuild, but because other people might be running flush-cache.sh
# This shouldn't rebuild, but because other people might be running flush-cache.py
# in parallel with us, we can't be 100% sure it won't. So don't test it.
#redo-ifchange always1
#[ "$(wc -l <always1.log)" -eq 1 ] || exit 21
./flush-cache.sh
./flush-cache.py
redo-ifchange always1
. ./skip-if-minimal-do.sh
[ "$(wc -l <always1.log)" -eq 2 ] || exit 31
./flush-cache.sh
./flush-cache.py
redo-ifchange always1
[ "$(wc -l <always1.log)" -eq 3 ] || exit 41
cd ..
./t/flush-cache.sh
./t/flush-cache.py
redo-ifchange t/always1
[ "$(wc -l <t/always1.log)" -eq 4 ] || exit 51

View file

@ -4,15 +4,15 @@ rm -f chdir1
redo chdir2
redo chdir3
./flush-cache.sh
./flush-cache.py
redo-ifchange chdir3
rm -f chdir1
./flush-cache.sh
./flush-cache.py
redo-ifchange chdir3
[ -e chdir1 ] || exit 77
rm -f chdir1
./flush-cache.sh
./flush-cache.py
redo-ifchange chdir3
[ -e chdir1 ] || exit 78

View file

@ -1,10 +1,10 @@
rm -f *.out *.log
../../flush-cache.sh
../../flush-cache.py
redo-ifchange 1.out 2.out
[ "$(cat 1.log | wc -l)" -eq 1 ] || exit 55
[ "$(cat 2.log | wc -l)" -eq 1 ] || exit 56
../../flush-cache.sh
../../flush-cache.py
touch 1.in
redo-ifchange 1.out 2.out
[ "$(cat 2.log | wc -l)" -eq 1 ] || exit 58

View file

@ -1,11 +1,11 @@
rm -f log dir1/log dir1/stinky
touch t1.do
../../flush-cache.sh
../../flush-cache.py
redo t1
touch t1.do
../../flush-cache.sh
../../flush-cache.py
redo t1
../../flush-cache.sh
../../flush-cache.py
redo-ifchange t1
C1="$(wc -l <dir1/log)"
C2="$(wc -l <log)"

View file

@ -3,7 +3,7 @@ rm -f static.log
redo static1 static2
touch static.in
../flush-cache.sh
../flush-cache.py
redo-ifchange static1 static2
COUNT=$(wc -l <static.log)

View file

@ -1,19 +1,19 @@
rm -f genfile2 genfile2.do genfile.log
echo echo hello >genfile2.do
../flush-cache.sh
../flush-cache.py
redo genfile1
# this will cause a rebuild:
# genfile1 depends on genfile2 depends on genfile2.do
rm -f genfile2.do
../flush-cache.sh
../flush-cache.py
redo-ifchange genfile1
# but genfile2.do was gone last time, so genfile2 no longer depends on it.
# thus, it can be considered up-to-date. Prior versions of redo had a bug
# where the dependency on genfile2.do was never dropped.
../flush-cache.sh
../flush-cache.py
redo-ifchange genfile1
COUNT=$(wc -l <genfile.log)

View file

@ -6,7 +6,7 @@ if [ -e t1a ]; then
else
BEFORE=
fi
../flush-cache.sh
../flush-cache.py
redo-ifchange t1a # it definitely had to rebuild because t1dep changed
AFTER="$(cat t1a)"
if [ "$BEFORE" = "$AFTER" ]; then

21
t/flush-cache.py Executable file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env python
import os, os.path, sqlite3, sys
if "DO_BUILT" in os.environ:
sys.exit(0)
print >>sys.stderr, "Flushing redo cache..."
db_file = os.path.join(os.environ["REDO_BASE"], ".redo", "db.sqlite3")
db_con = sqlite3.connect(db_file, timeout=5000)
db_con.executescript("pragma synchronous = off;"
"update Files set checked_runid=checked_runid-1, "
" changed_runid=changed_runid-1, "
" failed_runid=failed_runid-1;")
db_con.commit()
db_con.close()

View file

@ -1,12 +0,0 @@
#!/bin/sh
#echo "Flushing redo cache..." >&2
if [ -z "$DO_BUILT" ]; then
(
echo ".timeout 5000"
echo "pragma synchronous = off;"
echo "update Files set checked_runid=checked_runid-1, " \
" changed_runid=changed_runid-1, " \
" failed_runid=failed_runid-1;"
) | sqlite3 "$REDO_BASE/.redo/db.sqlite3"
fi

View file

@ -10,11 +10,11 @@ for d in 1 2; do
[ "$(wc -l <ifcreate$d.log)" -eq 1 ] || exit ${d}1
redo-ifchange ifcreate$d
[ "$(wc -l <ifcreate$d.log)" -eq 1 ] || exit ${d}2
./flush-cache.sh
./flush-cache.py
touch ifcreate$d.dep
redo-ifchange ifcreate$d
[ "$(wc -l <ifcreate$d.log)" -eq 2 ] || exit ${d}3
./flush-cache.sh
./flush-cache.py
rm ifcreate$d.dep
redo-ifchange ifcreate$d
[ "$(wc -l <ifcreate$d.log)" -eq 3 ] || exit ${d}4

View file

@ -2,7 +2,7 @@
rm -f makedir.log
redo makedir
touch makedir/outfile
./flush-cache.sh
./flush-cache.py
redo-ifchange makedir
COUNT=$(wc -l <makedir.log)
[ "$COUNT" -eq 1 ] || exit 99

View file

@ -1,32 +1,32 @@
rm -f stampy usestamp usestamp2 stampy.log usestamp.log usestamp2.log
echo one >inp
../flush-cache.sh
../flush-cache.py
redo stampy
[ "$(wc -l <stampy.log)" -eq 1 ] || exit 11
# stampy already exists, so we won't generate it a second time, even though
# usestamp depends on it.
../flush-cache.sh
../flush-cache.py
redo-ifchange usestamp
[ "$(wc -l <stampy.log)" -eq 1 ] || exit 21
[ "$(wc -l <usestamp.log)" -eq 1 ] || exit 12
../flush-cache.sh
../flush-cache.py
redo stampy
. ../skip-if-minimal-do.sh
[ "$(wc -l <stampy.log)" -eq 2 ] || exit 31
[ "$(wc -l <usestamp.log)" -eq 1 ] || exit 32
# same as above: stampy is already up-to-date, so it won't be redone.
../flush-cache.sh
../flush-cache.py
redo-ifchange usestamp
[ "$(wc -l <stampy.log)" -eq 2 ] || exit 41
[ "$(wc -l <usestamp.log)" -eq 1 ] || exit 42
# stampy depends on bob, so we'll have to rebuild stampy automatically. But
# stampy's checksum will still be identical.
../flush-cache.sh
../flush-cache.py
redo bob
redo-ifchange usestamp
[ "$(wc -l <stampy.log)" -eq 3 ] || exit 43
@ -34,13 +34,13 @@ redo-ifchange usestamp
# Make sure the previous step correctly marked stampy and usestamp as up-to-date
# even though *neither* of them is newer than bob.
../flush-cache.sh
../flush-cache.py
redo-ifchange usestamp
[ "$(wc -l <stampy.log)" -eq 3 ] || exit 45
[ "$(wc -l <usestamp.log)" -eq 1 ] || exit 46
# now we're changing the contents of stampy.
../flush-cache.sh
../flush-cache.py
echo two >inp
redo stampy
[ "$(wc -l <stampy.log)" -eq 4 ] || exit 51
@ -53,7 +53,7 @@ redo-ifchange usestamp usestamp2
# when we delete the file and it gets regenerated identically, it's as good as
# never having been deleted. So usestamp won't need to change.
../flush-cache.sh
../flush-cache.py
rm -f stampy
redo-ifchange usestamp usestamp2
[ "$(wc -l <stampy.log)" -eq 5 ] || exit 71
@ -61,7 +61,7 @@ redo-ifchange usestamp usestamp2
[ "$(wc -l <usestamp2.log)" -eq 1 ] || exit 73
# this simple test used to cause a deadlock.
../flush-cache.sh
../flush-cache.py
rm -f stampy
redo-ifchange stampy
[ "$(wc -l <stampy.log)" -eq 6 ] || exit 74