Skip to content

Commit 2e23b86

Browse files
authored
test/run-roundtrip.py: test roundtrip even with --stdout (#2505)
1 parent 765b47d commit 2e23b86

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

test/regress/write-memuse.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
;;; TOOL: run-roundtrip
2-
;;; ARGS*: --enable-multi-memory --debug-names
2+
;;; ARGS*: --enable-multi-memory --debug-names --stdout
33
(memory 0)
44
(memory $k (data))
5+
(;; STDOUT ;;;
6+
(module
7+
(memory (;0;) 0)
8+
(memory $k 0 0)
9+
(data (;0;) (memory $k) (i32.const 0) ""))
10+
;;; STDOUT ;;)

test/run-roundtrip.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def FilesAreEqual(filename1, filename2, verbose=False):
5555
return (OK, '')
5656

5757

58-
def DoRoundtrip(wat2wasm, wasm2wat, out_dir, filename, verbose, stdout):
58+
def DoRoundtrip(wat2wasm, wasm2wat, out_dir, filename, verbose, stdout, skip_roundtrip_check):
5959
basename = os.path.basename(filename)
6060
basename_noext = os.path.splitext(basename)[0]
6161
wasm1_file = os.path.join(out_dir, basename_noext + '-1.wasm')
@@ -75,9 +75,9 @@ def DoRoundtrip(wat2wasm, wasm2wat, out_dir, filename, verbose, stdout):
7575
if stdout:
7676
with open(wat2_file) as f:
7777
sys.stdout.write(f.read())
78+
if skip_roundtrip_check:
7879
return (OK, '')
79-
else:
80-
return FilesAreEqual(wasm1_file, wasm3_file, verbose)
80+
return FilesAreEqual(wasm1_file, wasm3_file, verbose)
8181

8282

8383
def main(args):
@@ -90,7 +90,7 @@ def main(args):
9090
default=find_exe.GetDefaultPath(),
9191
help='directory to search for all executables.')
9292
parser.add_argument('--stdout', action='store_true',
93-
help='do one roundtrip and write wat output to stdout')
93+
help='write wat output to stdout')
9494
parser.add_argument('--no-error-cmdline',
9595
help='don\'t display the subprocess\'s commandline when '
9696
'an error occurs', dest='error_cmdline',
@@ -100,7 +100,9 @@ def main(args):
100100
action='store_true')
101101
parser.add_argument('--no-check', action='store_true')
102102
parser.add_argument('--debug-names', action='store_true')
103-
parser.add_argument('--generate-names', action='store_true')
103+
# --generate-names modifies name section, so skip roundtrip check
104+
parser.add_argument('--generate-names', action='store_true',
105+
help="write debug names and skip end-to-end roundtrip check")
104106
parser.add_argument('--fold-exprs', action='store_true')
105107
parser.add_argument('--enable-exceptions', action='store_true')
106108
parser.add_argument('--enable-saturating-float-to-int', action='store_true')
@@ -115,7 +117,9 @@ def main(args):
115117
parser.add_argument('--enable-annotations', action='store_true')
116118
parser.add_argument('--enable-code-metadata', action='store_true')
117119
parser.add_argument('--enable-custom-page-sizes', action='store_true')
118-
parser.add_argument('--inline-exports', action='store_true')
120+
# --inline-exports can reorder exports, so skip roundtrip check
121+
parser.add_argument('--inline-exports', action='store_true',
122+
help="write exports inline and skip end-to-end roundtrip check")
119123
parser.add_argument('--inline-imports', action='store_true')
120124
parser.add_argument('--reloc', action='store_true')
121125
parser.add_argument('file', help='test file.')
@@ -178,9 +182,10 @@ def main(args):
178182
sys.stderr.write('File not found: %s\n' % filename)
179183
return ERROR
180184

185+
skip_roundtrip_check = options.generate_names or options.inline_exports
181186
with utils.TempDirectory(options.out_dir, 'roundtrip-') as out_dir:
182187
result, msg = DoRoundtrip(wat2wasm, wasm2wat, out_dir, filename,
183-
options.verbose, options.stdout)
188+
options.verbose, options.stdout, skip_roundtrip_check)
184189
if result == ERROR:
185190
sys.stderr.write(msg)
186191
return result

0 commit comments

Comments
 (0)