summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile.am6
-rwxr-xr-xtest/regress.py131
-rw-r--r--test/regress/205.test13
4 files changed, 150 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 2ce89e2f..0abdd0ab 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,7 @@
/ChangeLog
/Makefile
/Makefile.in
+/RegressionTests
/TAGS
/UnitTests
/acconf.h
diff --git a/Makefile.am b/Makefile.am
index 87eca602..9dd37afe 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -217,7 +217,7 @@ endif
######################################################################
-TESTS = UnitTests
+TESTS = UnitTests RegressionTests
if HAVE_BOOST_PYTHON
TESTS += PyUnitTests
endif
@@ -247,6 +247,10 @@ PyUnitTests: $(srcdir)/test/python/PyUnitTests.py
| sed "s/%builddir%/$(ESC_builddir)/g" > $@
chmod 755 $@
+RegressionTests: $(srcdir)/test/regress.py
+ echo "python $(srcdir)/test/regress.py $(top_builddir)/ledger$(EXEEXT) $(srcdir)/test/regress" > $@
+ chmod 755 $@
+
fullcheck: check
MallocGuardEdges=1 \
MallocScribble=1 \
diff --git a/test/regress.py b/test/regress.py
new file mode 100755
index 00000000..e3b1e478
--- /dev/null
+++ b/test/regress.py
@@ -0,0 +1,131 @@
+#!/usr/bin/env python
+
+import sys
+import os
+import re
+import string
+import difflib
+import tempfile
+
+from subprocess import *
+
+ledger = sys.argv[1]
+tests = sys.argv[2]
+
+if not os.path.isfile(ledger):
+ sys.exit(1)
+if not os.path.isdir(tests):
+ sys.exit(1)
+
+succeeded = 0
+failed = 0
+
+def test_regression(file):
+ global succeeded, failed
+
+ bug = open(file)
+ command = bug.readline()
+
+ line = bug.readline()
+ assert "<<<\n" == line
+ line = bug.readline()
+
+ input = []
+ while line != ">>>1\n":
+ input.append(line)
+ line = bug.readline()
+ line = bug.readline()
+
+ use_stdin = False
+ if command.startswith("-f - "):
+ use_stdin = True
+
+ command = ("%s" % ledger) + command
+ else:
+ tempdata = tempfile.mkstemp()
+
+ os.write(tempdata[0], string.join(input))
+ os.close(tempdata[0])
+
+ command = ("%s -f \"%s\" " % (ledger, tempdata[1])) + command
+
+ output = []
+ while line != ">>>2\n":
+ output.append(line)
+ line = bug.readline()
+ line = bug.readline()
+
+ error = []
+ while not line.startswith("==="):
+ error.append(line)
+ line = bug.readline()
+
+ match = re.match('=== ([0-9]+)', line)
+ assert match
+
+ exitcode = int(match.group(1))
+
+ p = Popen(command[:-1], shell=True,
+ stdin=PIPE, stdout=PIPE, stderr=PIPE,
+ close_fds=True)
+
+ if use_stdin:
+ p.stdin.write(string.join(input))
+ p.stdin.close()
+
+ success = True
+
+ printed = False
+ index = 0
+ for line in difflib.unified_diff(output, p.stdout.readlines()):
+ index += 1
+ if index < 3:
+ continue
+ if not printed:
+ if success: print
+ print "Regression failure in output from %s:" % os.path.basename(file)
+ if success: failed += 1
+ success = False
+ printed = True
+ print " ", line,
+
+ printed = False
+ index = 0
+ for line in difflib.unified_diff(error, p.stderr.readlines()):
+ index += 1
+ if index < 3:
+ continue
+ if not printed:
+ if success: print
+ print "Regression failure in error output from %s:" % os.path.basename(file)
+ if success: failed += 1
+ success = False
+ printed = True
+ print " ", line,
+
+ if exitcode != p.wait():
+ if success: print
+ if success: failed += 1
+ success = False
+ print "Regression failure in exitcode from %s: %d (expected) != %d" \
+ % (os.path.basename(file), exitcode, p.returncode)
+
+ if success:
+ succeeded += 1
+ print ".",
+
+ if not use_stdin:
+ os.remove(tempdata[1])
+
+for test in os.listdir(tests):
+ if re.search('\.test$', test):
+ test_regression(os.path.join(tests, test))
+
+print
+if succeeded > 0:
+ print "OK (%d) " % succeeded,
+if failed > 0:
+ print "FAILED (%d)" % failed,
+print
+
+sys.exit(failed)
diff --git a/test/regress/205.test b/test/regress/205.test
new file mode 100644
index 00000000..0ad16aad
--- /dev/null
+++ b/test/regress/205.test
@@ -0,0 +1,13 @@
+bal
+<<<
+2007/02/02 RD VMMXX
+ Assets:Investments:Vanguard:VMMXX 0.350 VMMXX @ $1.00
+ Income:Dividends:Vanguard:VMMXX $-0.35
+>>>1
+ 0.350 VMMXX Assets
+ $-0.35 Income
+--------------------
+ $-0.35
+ 0.350 VMMXX
+>>>2
+=== 0