From 267e4b55f8c2f598ea5ea44d5df88d83bfb3ebac Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Mon, 19 Mar 2018 17:02:40 -0400 Subject: include the filename in erroneous diff output where possible (#1452) Failing test cases often start out with: ``` incorrect output, diff: --- expected +++ actual ``` which makes it difficult to figure out where the expected output might live. That information can be derived from examining the tests, of course, but it'd be much nicer if it were provided in the diff to see straightaway. We do this by introducing a new check, one which takes a filename of expected output, which then enables us to display the failing file, e.g.: ``` incorrect output, diff: --- /home/froydnj/src/binaryen.git/test/passes/code-folding.txt +++ actual ``` which is arguably nicer. Having this new check also enables reducing some boilerplate `open(...).read()` calls in various places. There are still a few places using `fail_if_not_identical`, usually because `.strip()` is used on the expected output. --- scripts/test/wasm2asm.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'scripts/test/wasm2asm.py') diff --git a/scripts/test/wasm2asm.py b/scripts/test/wasm2asm.py index 6e6b32c81..81cb9b5c5 100755 --- a/scripts/test/wasm2asm.py +++ b/scripts/test/wasm2asm.py @@ -4,7 +4,8 @@ import os from support import run_command from shared import ( - WASM2ASM, MOZJS, NODEJS, fail_if_not_identical, options, tests + WASM2ASM, MOZJS, NODEJS, fail_if_not_identical, options, tests, + fail_if_not_identical_to_file ) # tests with i64s, invokes, etc. @@ -33,8 +34,7 @@ def test_wasm2asm_output(): cmd = WASM2ASM + [os.path.join(options.binaryen_test, wasm)] out = run_command(cmd) - expected = open(expected_file).read() - fail_if_not_identical(out, expected) + fail_if_not_identical_to_file(out, expected_file) if not NODEJS and not MOZJS: print 'No JS interpreters. Skipping spec tests.' @@ -79,13 +79,11 @@ def test_asserts_output(): wasm = os.path.join(options.binaryen_test, wasm) cmd = WASM2ASM + [wasm, '--allow-asserts'] out = run_command(cmd) - expected = open(asserts_expected_file).read() - fail_if_not_identical(out, expected) + fail_if_not_identical_to_file(out, asserts_expected_file) cmd += ['--pedantic'] out = run_command(cmd) - expected = open(traps_expected_file).read() - fail_if_not_identical(out, expected) + fail_if_not_identical_to_file(out, traps_expected_file) def test_wasm2asm(): -- cgit v1.2.3