diff options
author | John Wiegley <johnw@newartisans.com> | 2011-02-12 17:20:00 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2011-02-12 17:55:56 -0500 |
commit | 512542552b3e3e78f610f3d3f2fd1c8169188324 (patch) | |
tree | 91d350873ffdfc3a5dcca10b2a7558f05d78523d /test/RegressTests.py | |
parent | a69cd37fa240135eef2abd5f8a86760d3a0e9a15 (diff) | |
download | fork-ledger-512542552b3e3e78f610f3d3f2fd1c8169188324.tar.gz fork-ledger-512542552b3e3e78f610f3d3f2fd1c8169188324.tar.bz2 fork-ledger-512542552b3e3e78f610f3d3f2fd1c8169188324.zip |
When a test fails, show the command that failed
Diffstat (limited to 'test/RegressTests.py')
-rwxr-xr-x | test/RegressTests.py | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/test/RegressTests.py b/test/RegressTests.py index b668e51f..e176f8fc 100755 --- a/test/RegressTests.py +++ b/test/RegressTests.py @@ -87,6 +87,12 @@ class RegressFile(object): return test['command'] and test + def notify_user(self, msg, test): + print msg + print "--" + print test['command'], + print "--" + def run_test(self, test): use_stdin = False if test['command'].find("-f - ") != -1: @@ -112,48 +118,48 @@ class RegressFile(object): success = True printed = False index = 0 - for line in unified_diff(test['output'], harness.readlines(p.stdout)): - index += 1 - if index < 3: - continue - if not printed: - if success: print - print "Regression failure in output from %s:" % \ - os.path.basename(self.filename) - success = False - printed = True - print " ", line, + if test['output'] is not None: + for line in unified_diff(test['output'], harness.readlines(p.stdout)): + index += 1 + if index < 3: + continue + if not printed: + if success: print + self.notify_user("Regression failure in output from %s:" % self.filename, test) + success = False + printed = True + print " ", line, printed = False index = 0 - for line in unified_diff([re.sub('\$FILE', tempdata[1], line) - for line in test['error']], - harness.readlines(p.stderr)): - index += 1 - if index < 3: - continue - if not printed: - if success: print - print "Regression failure in error output from %s:" % \ - os.path.basename(self.filename) - success = False - printed = True - print " ", line, - - if test['exitcode'] == p.wait(): + if test['error'] is not None: + for line in unified_diff([re.sub('\$FILE', tempdata[1], line) + for line in test['error']], + harness.readlines(p.stderr)): + index += 1 + if index < 3: + continue + if not printed: + if success: print + self.notify_user("Regression failure in error output from %s:" % self.filename, test) + success = False + printed = True + print " ", line, + + if not use_stdin: + os.remove(tempdata[1]) + + if test['exitcode'] is None or test['exitcode'] == p.wait(): if success: harness.success() else: harness.failure() else: if success: print - print "Regression failure in exitcode from %s: %d (expected) != %d" % \ - (os.path.basename(self.filename), test['exitcode'], p.returncode) + self.notify_user("Regression failure in exit code (%d (expected) != %d) from %s:" + % (test['exitcode'], p.returncode), test, self.filename) harness.failure() - if not use_stdin: - os.remove(tempdata[1]) - def run_tests(self): test = self.read_test() while test: |