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 import re
def clean(num): 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 running_total = 0.0
index = 1 index = 1
last_line = "" last_line = ""
errors = 0 errors = 0
report = sys.argv[1] args = sys.argv[1]
for line in os.popen("./ledger -f tools/standard.dat -e 2004/4 %s reg %s" % for line in os.popen(re.sub('\$cmd', 'reg', args)):
(report, sys.argv[2])):
match = re.match("\\s*([-$,0-9.]+)\\s+([-$,0-9.]+)", line[55:]) match = re.match("\\s*([-$,0-9.]+)\\s+([-$,0-9.]+)", line[55:])
if not match: if not match:
continue continue
@ -25,10 +29,10 @@ for line in os.popen("./ledger -f tools/standard.dat -e 2004/4 %s reg %s" %
running_total += value running_total += value
diff = abs(running_total - total) 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 diff = 0.0
if diff > 0.001: 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) (running_total - total, running_total, total, index)
print line, print line,
running_total = total 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 balance_total = 0.0
for line in os.popen("./ledger -f tools/standard.dat -e 2004/4 %s bal %s" % for line in os.popen(re.sub('\$cmd', 'bal', args)):
(report, sys.argv[2])):
if line[0] != '-': if line[0] != '-':
balance_total = clean(line[:20]) balance_total = clean(line[:20])
diff = abs(balance_total - running_total) 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 diff = 0.0
if diff > 0.001: if diff > 0.001:
print 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) (balance_total - running_total, balance_total, running_total)
print last_line, print last_line,
errors += 1 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 errors=0
if [ ! -f tools/standard.dat ]; then for test in \
exit 0 "-O \$cmd 0ecbb1b15e2cf3e515cc0f8533e5bb0fb2326728" \
fi "-B \$cmd c56a21d23a6535184e7152ee138c28974f14280c" \
"-V \$cmd c56a21d23a6535184e7152ee138c28974f14280c" \
for test in \ "-G \$cmd c56a21d23a6535184e7152ee138c28974f14280c" \
"-O nrl:checking" \ "-B \$cmd c0226fafdf9e6711ac9121cf263e2d50791859cb" \
"-O ^expenses" \ "-V \$cmd c0226fafdf9e6711ac9121cf263e2d50791859cb" \
"-B 401" \ "-G \$cmd c0226fafdf9e6711ac9121cf263e2d50791859cb"
"-V 401" \
"-G 401" \
"-B ira" \
"-V ira" \
"-G ira" \
"-B retire" \
"-V retire" \
"-G retire"
do do
echo testing: $test echo testing: $test
python tests/confirm.py $test python tools/confirm.py "ledger -f tools/standard.dat $test"
errors=`expr $errors + $?` errors=`expr $errors + $?`
done done
if [ $errors = 0 ]; then
echo All tests completed successfully.
fi
exit $errors exit $errors

5631
tools/standard.dat Normal file

File diff suppressed because it is too large Load diff