Restored the functionality of tools/regtest

This commit is contained in:
John Wiegley 2009-02-24 22:11:59 -04:00
parent 5a194cbdf4
commit a364b1d4ac
4 changed files with 5663 additions and 27 deletions

View file

@ -7,16 +7,20 @@ import os
import re
def clean(num):
return float(re.sub("(\s+|\$|,)","", num))
num = re.sub("(\s+|\$|,)","", num)
m = re.search("([-0-9.]+)", num)
if m:
return float(m.group(1))
else:
return float(num)
running_total = 0.0
index = 1
last_line = ""
errors = 0
report = sys.argv[1]
for line in os.popen("./ledger -f tools/standard.dat -e 2004/4 %s reg %s" %
(report, sys.argv[2])):
args = sys.argv[1]
for line in os.popen(re.sub('\$cmd', 'reg', args)):
match = re.match("\\s*([-$,0-9.]+)\\s+([-$,0-9.]+)", line[55:])
if not match:
continue
@ -25,10 +29,10 @@ for line in os.popen("./ledger -f tools/standard.dat -e 2004/4 %s reg %s" %
running_total += value
diff = abs(running_total - total)
if report == "-V" or report == "-G" and diff < 0.015:
if (re.search(' -V ', args) or re.search(' -G ', args)) and diff < 0.015:
diff = 0.0
if diff > 0.001:
print "! discrepancy of %.2f (%.2f - %.2f) at line %d:" % \
print "DISCREPANCY: %.3f (%.3f - %.3f) at line %d:" % \
(running_total - total, running_total, total, index)
print line,
running_total = total
@ -39,17 +43,16 @@ for line in os.popen("./ledger -f tools/standard.dat -e 2004/4 %s reg %s" %
balance_total = 0.0
for line in os.popen("./ledger -f tools/standard.dat -e 2004/4 %s bal %s" %
(report, sys.argv[2])):
for line in os.popen(re.sub('\$cmd', 'bal', args)):
if line[0] != '-':
balance_total = clean(line[:20])
diff = abs(balance_total - running_total)
if report == "-V" or report == "-G" and diff < 0.015:
if (re.search(' -V ', args) or re.search(' -G ', args)) and diff < 0.015:
diff = 0.0
if diff > 0.001:
print
print "! discrepancy of %.2f (%.2f - %.2f) between register and balance" % \
print "DISCREPANCY: %.3f (%.3f - %.3f) between register and balance" % \
(balance_total - running_total, balance_total, running_total)
print last_line,
errors += 1

7
tools/mkmondo Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
if [ ! -f tools/mondo.dat ]; then
for i in $(seq 1 250) ; do
cat tools/standard.dat >> tools/mondo.dat
done
fi

View file

@ -2,26 +2,21 @@
errors=0
if [ ! -f tools/standard.dat ]; then
exit 0
fi
for test in \
"-O nrl:checking" \
"-O ^expenses" \
"-B 401" \
"-V 401" \
"-G 401" \
"-B ira" \
"-V ira" \
"-G ira" \
"-B retire" \
"-V retire" \
"-G retire"
for test in \
"-O \$cmd 0ecbb1b15e2cf3e515cc0f8533e5bb0fb2326728" \
"-B \$cmd c56a21d23a6535184e7152ee138c28974f14280c" \
"-V \$cmd c56a21d23a6535184e7152ee138c28974f14280c" \
"-G \$cmd c56a21d23a6535184e7152ee138c28974f14280c" \
"-B \$cmd c0226fafdf9e6711ac9121cf263e2d50791859cb" \
"-V \$cmd c0226fafdf9e6711ac9121cf263e2d50791859cb" \
"-G \$cmd c0226fafdf9e6711ac9121cf263e2d50791859cb"
do
echo testing: $test
python tests/confirm.py $test
python tools/confirm.py "ledger -f tools/standard.dat $test"
errors=`expr $errors + $?`
done
if [ $errors = 0 ]; then
echo All tests completed successfully.
fi
exit $errors

5631
tools/standard.dat Normal file

File diff suppressed because it is too large Load diff