diff options
author | Loppin Vincent <vincent.loppin@gmail.com> | 2018-06-20 21:58:01 +0200 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2018-06-20 12:58:01 -0700 |
commit | 487cee5ac474ec5971fad94ecbd85075ba5dbc92 (patch) | |
tree | 1d19d20dd7a0390afc48b90a8ffe06843cc2440d | |
parent | 4730172cd9114d03c448e9420628764fc2e72723 (diff) | |
download | binaryen-487cee5ac474ec5971fad94ecbd85075ba5dbc92.tar.gz binaryen-487cee5ac474ec5971fad94ecbd85075ba5dbc92.tar.bz2 binaryen-487cee5ac474ec5971fad94ecbd85075ba5dbc92.zip |
Fix check.py on windows platform (#1605)
Fix some file reading & endline issues on windows platform.
-rwxr-xr-x | check.py | 6 | ||||
-rw-r--r-- | scripts/test/shared.py | 2 | ||||
-rw-r--r-- | scripts/test/support.py | 7 |
3 files changed, 8 insertions, 7 deletions
@@ -105,7 +105,7 @@ def run_wasm_opt_tests(): actual = '' for module, asserts in split_wast(t): assert len(asserts) == 0 - with open('split.wast', 'w') as o: + with open('split.wast', "wb" if binary else 'w') as o: o.write(module) cmd = WASM_OPT + opts + ['split.wast', '--print'] curr = run_command(cmd) @@ -139,12 +139,12 @@ def run_wasm_opt_tests(): wasm = os.path.basename(t).replace('.wast', '') cmd = WASM_OPT + [os.path.join(options.binaryen_test, 'print', t), '--print'] print ' ', ' '.join(cmd) - actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).communicate() expected_file = os.path.join(options.binaryen_test, 'print', wasm + '.txt') fail_if_not_identical_to_file(actual, expected_file) cmd = WASM_OPT + [os.path.join(options.binaryen_test, 'print', t), '--print-minified'] print ' ', ' '.join(cmd) - actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).communicate() fail_if_not_identical(actual.strip(), open(os.path.join(options.binaryen_test, 'print', wasm + '.minified.txt')).read().strip()) print '\n[ checking wasm-opt testcases... ]\n' diff --git a/scripts/test/shared.py b/scripts/test/shared.py index a0bce3dd5..52dd74fd7 100644 --- a/scripts/test/shared.py +++ b/scripts/test/shared.py @@ -312,7 +312,7 @@ def fail_if_not_contained(actual, expected): def fail_if_not_identical_to_file(actual, expected_file): - with open(expected_file, 'rb') as f: + with open(expected_file, 'rb' if expected_file.endswith(".wasm") else 'r') as f: fail_if_not_identical(actual, f.read(), fromfile=expected_file) diff --git a/scripts/test/support.py b/scripts/test/support.py index 23a91df59..f23e1c4de 100644 --- a/scripts/test/support.py +++ b/scripts/test/support.py @@ -87,16 +87,17 @@ def untar(tarfile, outdir): shutil.rmtree(tmpdir) -def split_wast(wast): +def split_wast(wastFile): # .wast files can contain multiple modules, and assertions for each one. # this splits out a wast into [(module, assertions), ..] # we ignore module invalidity tests here. - wast = open(wast).read() + wast = open(wastFile, 'rb').read() # if it's a binary, leave it as is if wast[0] == '\0': return [[wast, '']] + wast = open(wastFile, 'r').read() ret = [] def to_end(j): @@ -152,7 +153,7 @@ def run_command(cmd, expected_status=0, stderr=None, "Can't redirect stderr if using expected_err" stderr = subprocess.PIPE print 'executing: ', ' '.join(cmd) - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=stderr) + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=stderr, universal_newlines=True) out, err = proc.communicate() code = proc.returncode if code != expected_status: |