From 0e691e76dbd928b4aa919cbb9788c805e34937dc Mon Sep 17 00:00:00 2001 From: Evan Mallory Date: Thu, 22 Sep 2016 18:51:10 -0400 Subject: Fix test harness to work with msys2 With this change, 97% of the tests pass. See the build on appveyor for more info: https://ci.appveyor.com/project/Evan/ledger/build/build-49 I'll follow up with another PR to fix some of the remaining broken tests --- test/RegressTests.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'test/RegressTests.py') diff --git a/test/RegressTests.py b/test/RegressTests.py index a5bab42d..58869edc 100755 --- a/test/RegressTests.py +++ b/test/RegressTests.py @@ -98,6 +98,13 @@ class RegressFile(object): def run_test(self, test): use_stdin = False + if sys.platform == 'win32': + test['command'] = test['command'].replace('/dev/null', 'nul') + # There is no equivalent to /dev/stdout, /dev/stderr, /dev/stdin + # on Windows, so skip tests that require them. + if '/dev/std' in test['command']: + harness.success() + return if test['command'].find("-f ") != -1: test['command'] = '$ledger ' + test['command'] if re.search("-f (-|/dev/stdin)(\s|$)", test['command']): @@ -122,7 +129,16 @@ class RegressFile(object): printed = False index = 0 if test['output'] is not None: - for line in unified_diff(test['output'], harness.readlines(p.stdout)): + process_output = harness.readlines(p.stdout) + expected_output = test['output'] + if sys.platform == 'win32': + process_output = [l.replace('\r\n', '\n').replace('\\', '/') + for l in process_output] + # Replace \ with / in the expected output because the line above + # makes it impossible for the process output to have a \. + expected_output = [l.replace('\\', '/') for l in expected_output] + + for line in unified_diff(expected_output, process_output): index += 1 if index < 3: continue @@ -135,8 +151,14 @@ class RegressFile(object): printed = False index = 0 - if test['error'] is not None: - for line in unified_diff(test['error'], harness.readlines(p.stderr)): + process_error = harness.readlines(p.stderr) + if test['error'] is not None or process_error is not None: + if test['error'] is None: + test['error'] = [] + if sys.platform == 'win32': + process_error = [l.replace('\r\n', '\n').replace('\\', '/') + for l in process_error] + for line in unified_diff(test['error'], process_error): index += 1 if index < 3: continue -- cgit v1.2.3