Rename flush-cache.py to flush-cache, and rearrange the code a bit.

It was working fine, but the style wasn't exactly the way I like it, because
I'm unnecessarily picky. :)

Also, removed the file extension since we should probably learn from the
fact that it's already been rewritten once from one language to another.
Who knows, maybe it will be again someday.
This commit is contained in:
Avery Pennarun 2011-02-23 01:24:48 -08:00
commit 94c254de77
12 changed files with 47 additions and 51 deletions

View file

@ -5,21 +5,22 @@ 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.py
# in parallel with us, we can't be 100% sure it won't. So don't test it.
# This shouldn't rebuild, but because other people might be running
# flush-cache 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.py
./flush-cache
redo-ifchange always1
. ./skip-if-minimal-do.sh
[ "$(wc -l <always1.log)" -eq 2 ] || exit 31
./flush-cache.py
./flush-cache
redo-ifchange always1
[ "$(wc -l <always1.log)" -eq 3 ] || exit 41
cd ..
./t/flush-cache.py
./t/flush-cache
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.py
./flush-cache
redo-ifchange chdir3
rm -f chdir1
./flush-cache.py
./flush-cache
redo-ifchange chdir3
[ -e chdir1 ] || exit 77
rm -f chdir1
./flush-cache.py
./flush-cache
redo-ifchange chdir3
[ -e chdir1 ] || exit 78

View file

@ -1,10 +1,10 @@
rm -f *.out *.log
../../flush-cache.py
../../flush-cache
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.py
../../flush-cache
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.py
../../flush-cache
redo t1
touch t1.do
../../flush-cache.py
../../flush-cache
redo t1
../../flush-cache.py
../../flush-cache
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.py
../flush-cache
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.py
../flush-cache
redo genfile1
# this will cause a rebuild:
# genfile1 depends on genfile2 depends on genfile2.do
rm -f genfile2.do
../flush-cache.py
../flush-cache
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.py
../flush-cache
redo-ifchange genfile1
COUNT=$(wc -l <genfile.log)

View file

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

16
t/flush-cache Executable file
View file

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

View file

@ -1,21 +0,0 @@
#!/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

@ -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.py
./flush-cache
touch ifcreate$d.dep
redo-ifchange ifcreate$d
[ "$(wc -l <ifcreate$d.log)" -eq 2 ] || exit ${d}3
./flush-cache.py
./flush-cache
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.py
./flush-cache
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.py
../flush-cache
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.py
../flush-cache
redo-ifchange usestamp
[ "$(wc -l <stampy.log)" -eq 1 ] || exit 21
[ "$(wc -l <usestamp.log)" -eq 1 ] || exit 12
../flush-cache.py
../flush-cache
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.py
../flush-cache
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.py
../flush-cache
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.py
../flush-cache
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.py
../flush-cache
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.py
../flush-cache
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.py
../flush-cache
rm -f stampy
redo-ifchange stampy
[ "$(wc -l <stampy.log)" -eq 6 ] || exit 74