diff options
author | Evan Mallory <schmave@gmail.com> | 2016-09-22 18:51:10 -0400 |
---|---|---|
committer | Evan Mallory <schmave@gmail.com> | 2016-09-23 08:14:30 -0400 |
commit | 0e691e76dbd928b4aa919cbb9788c805e34937dc (patch) | |
tree | 31b4d0c6a09c6e33b1c67b943dbff79adf14bd6a /test | |
parent | 132156766770da8340138aab117cf7e37787403c (diff) | |
download | fork-ledger-0e691e76dbd928b4aa919cbb9788c805e34937dc.tar.gz fork-ledger-0e691e76dbd928b4aa919cbb9788c805e34937dc.tar.bz2 fork-ledger-0e691e76dbd928b4aa919cbb9788c805e34937dc.zip |
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
Diffstat (limited to 'test')
-rwxr-xr-x | test/DocTests.py | 2 | ||||
-rwxr-xr-x | test/LedgerHarness.py | 7 | ||||
-rwxr-xr-x | test/RegressTests.py | 28 | ||||
-rw-r--r-- | test/regress/981.test | 3 |
4 files changed, 36 insertions, 4 deletions
diff --git a/test/DocTests.py b/test/DocTests.py index 7af7abc3..52632a7b 100755 --- a/test/DocTests.py +++ b/test/DocTests.py @@ -192,6 +192,8 @@ class DocTests: error = None try: verify = subprocess.check_output(command, stderr=subprocess.STDOUT) + if sys.platform == 'win32': + verify = verify.replace('\r\n', '\n') valid = (output == verify) or (not error and validation) except subprocess.CalledProcessError, e: error = e.output diff --git a/test/LedgerHarness.py b/test/LedgerHarness.py index 39a31286..63d6a0ec 100755 --- a/test/LedgerHarness.py +++ b/test/LedgerHarness.py @@ -86,6 +86,13 @@ class LedgerHarness: if os.path.isfile(valgrind) and '--verify' in insert: command = valgrind + ' -q ' + command + # If we are running under msys2, use bash to execute the test commands + if 'MSYSTEM' in os.environ: + bash_path = os.environ['MINGW_PREFIX'] + '/../usr/bin/bash.exe' + return Popen([bash_path, '-c', command], shell=False, + close_fds=False, env=env, stdin=PIPE, stdout=PIPE, + stderr=PIPE, cwd=self.sourcepath) + return Popen(command, shell=True, close_fds=True, env=env, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=self.sourcepath) 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 diff --git a/test/regress/981.test b/test/regress/981.test index 7a6ea5cf..2338b82a 100644 --- a/test/regress/981.test +++ b/test/regress/981.test @@ -24,5 +24,6 @@ Warning: "$FILE", line 15: Metadata check failed for (Project: foo): (value =~ / end test test reg --limit 'payee =~ /XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/' +__ERROR__ +Warning: "$FILE", line 15: Metadata check failed for (Project: foo): (value =~ /^(0ad|ankur|aptosid|archlinux|chakra|debian|debconf14|debconf15|debconf16|drizzle|ffmpeg|ffmpeg|fluxbox|freedesktop|freedombox|gallery|texmacs|haskell|jenkins|libreoffice|madwifi|mingw|openvas|openwrt|openbioinformatics|openembedded|openvoting|osunix|path64|plan9|postgresql|privoxy|smc|helios|tidesdk|tux4kids|yafaray|spi)$/) end test - |