Skip to content

Commit 42b61e3

Browse files
authored
Use wat over wast for text format filenames (#2518)
1 parent b232033 commit 42b61e3

68 files changed

Lines changed: 68 additions & 269 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,10 @@ endif()
379379
enable_testing()
380380

381381
add_test(NAME opt-unit
382-
COMMAND bin/wasm-opt test/unit.wast --flatten --ssa --metrics -O4 -Os --metrics)
382+
COMMAND bin/wasm-opt test/unit.wat --flatten --ssa --metrics -O4 -Os --metrics)
383383
add_test(NAME metrics-emcc
384384
COMMAND bin/wasm-opt test/emcc_hello_world.fromasm --metrics)
385385
add_test(NAME exec-unit
386-
COMMAND bin/wasm-opt test/unit.wast --fuzz-exec)
386+
COMMAND bin/wasm-opt test/unit.wat --fuzz-exec)
387387
add_test(NAME exec-hello
388-
COMMAND bin/wasm-opt test/hello_world.wast --fuzz-exec)
388+
COMMAND bin/wasm-opt test/hello_world.wat --fuzz-exec)

README.md

Lines changed: 5 additions & 5 deletions

auto_update_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def update_asm_js_tests():
7373

7474
def update_wasm_opt_tests():
7575
print('\n[ checking wasm-opt -o notation... ]\n')
76-
wast = os.path.join(shared.options.binaryen_test, 'hello_world.wast')
76+
wast = os.path.join(shared.options.binaryen_test, 'hello_world.wat')
7777
cmd = shared.WASM_OPT + [wast, '-o', 'a.wast', '-S']
7878
support.run_command(cmd)
7979
open(wast, 'w').write(open('a.wast').read())

check.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ def run_wasm_opt_tests():
7272
print('\n[ checking wasm-opt -o notation... ]\n')
7373

7474
for extra_args in [[], ['--no-validation']]:
75-
wast = os.path.join(shared.options.binaryen_test, 'hello_world.wast')
76-
shared.delete_from_orbit('a.wast')
77-
out = 'a.wast'
75+
wast = os.path.join(shared.options.binaryen_test, 'hello_world.wat')
76+
shared.delete_from_orbit('a.wat')
77+
out = 'a.wat'
7878
cmd = shared.WASM_OPT + [wast, '-o', out, '-S'] + extra_args
7979
support.run_command(cmd)
8080
shared.fail_if_not_identical_to_file(open(out).read(), wast)
8181

8282
print('\n[ checking wasm-opt binary reading/writing... ]\n')
8383

84-
shutil.copyfile(os.path.join(shared.options.binaryen_test, 'hello_world.wast'), 'a.wast')
84+
shutil.copyfile(os.path.join(shared.options.binaryen_test, 'hello_world.wat'), 'a.wat')
8585
shared.delete_from_orbit('a.wasm')
8686
shared.delete_from_orbit('b.wast')
87-
support.run_command(shared.WASM_OPT + ['a.wast', '-o', 'a.wasm'])
87+
support.run_command(shared.WASM_OPT + ['a.wat', '-o', 'a.wasm'])
8888
assert open('a.wasm', 'rb').read()[0] == 0, 'we emit binary by default'
8989
support.run_command(shared.WASM_OPT + ['a.wasm', '-o', 'b.wast', '-S'])
9090
assert open('b.wast', 'rb').read()[0] != 0, 'we emit text with -S'
@@ -222,9 +222,9 @@ def run_ctor_eval_tests():
222222
for t in shared.get_tests(shared.get_test_dir('ctor-eval'), ['.wast', '.wasm']):
223223
print('..', os.path.basename(t))
224224
ctors = open(t + '.ctors').read().strip()
225-
cmd = shared.WASM_CTOR_EVAL + [t, '-o', 'a.wast', '-S', '--ctors', ctors]
225+
cmd = shared.WASM_CTOR_EVAL + [t, '-o', 'a.wat', '-S', '--ctors', ctors]
226226
support.run_command(cmd)
227-
actual = open('a.wast').read()
227+
actual = open('a.wat').read()
228228
out = t + '.out'
229229
shared.fail_if_not_identical_to_file(actual, out)
230230

@@ -235,10 +235,10 @@ def run_wasm_metadce_tests():
235235
for t in shared.get_tests(shared.get_test_dir('metadce'), ['.wast', '.wasm']):
236236
print('..', os.path.basename(t))
237237
graph = t + '.graph.txt'
238-
cmd = shared.WASM_METADCE + [t, '--graph-file=' + graph, '-o', 'a.wast', '-S', '-all']
238+
cmd = shared.WASM_METADCE + [t, '--graph-file=' + graph, '-o', 'a.wat', '-S', '-all']
239239
stdout = support.run_command(cmd)
240240
expected = t + '.dced'
241-
with open('a.wast') as seen:
241+
with open('a.wat') as seen:
242242
shared.fail_if_not_identical_to_file(seen.read(), expected)
243243
shared.fail_if_not_identical_to_file(stdout, expected + '.stdout')
244244

@@ -257,8 +257,8 @@ def run_wasm_reduce_tests():
257257
support.run_command(shared.WASM_AS + [t, '-o', 'a.wasm'])
258258
support.run_command(shared.WASM_REDUCE + ['a.wasm', '--command=%s b.wasm --fuzz-exec -all' % shared.WASM_OPT[0], '-t', 'b.wasm', '-w', 'c.wasm', '--timeout=4'])
259259
expected = t + '.txt'
260-
support.run_command(shared.WASM_DIS + ['c.wasm', '-o', 'a.wast'])
261-
with open('a.wast') as seen:
260+
support.run_command(shared.WASM_DIS + ['c.wasm', '-o', 'a.wat'])
261+
with open('a.wat') as seen:
262262
shared.fail_if_not_identical_to_file(seen.read(), expected)
263263

264264
# run on a nontrivial fuzz testcase, for general coverage
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020
output_file = sys.argv[2]
2121

2222
with open(input_file) as f:
23-
wast = f.read()
23+
wat = f.read()
2424

2525
output = """\
26-
// Automatically generated by embedwast.py
26+
// Automatically generated by embedwat.py
2727
2828
#include "passes/intrinsics-module.h"
2929
3030
static const char theModule[%d] = {
31-
""" % (len(wast) + 1)
31+
""" % (len(wat) + 1)
3232

33-
for c in wast:
33+
for c in wat:
3434
output += str(ord(c)) + ', '
3535

3636
output += '''0

scripts/fuzz_opt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ def get_multiple_opt_choices():
536536
# possible feature options that are sometimes passed to the tools. this
537537
# contains the list of all possible feature flags we can disable (after
538538
# we enable all before that in the constant options)
539-
POSSIBLE_FEATURE_OPTS = run([in_bin('wasm-opt'), '--print-features', '-all', in_binaryen('test', 'hello_world.wast'), '-all']).replace('--enable', '--disable').strip().split('\n')
539+
POSSIBLE_FEATURE_OPTS = run([in_bin('wasm-opt'), '--print-features', '-all', in_binaryen('test', 'hello_world.wat'), '-all']).replace('--enable', '--disable').strip().split('\n')
540540
print('POSSIBLE_FEATURE_OPTS:', POSSIBLE_FEATURE_OPTS)
541541

542542
if __name__ == '__main__':

scripts/test/lld.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ def args_for_finalize(filename):
3232
def test_wasm_emscripten_finalize():
3333
print('\n[ checking wasm-emscripten-finalize testcases... ]\n')
3434

35-
for wast_path in shared.get_tests(shared.get_test_dir('lld'), ['.wast']):
36-
print('..', wast_path)
37-
is_passive = '.passive.' in wast_path
38-
mem_file = wast_path + '.mem'
35+
for wat_path in shared.get_tests(shared.get_test_dir('lld'), ['.wat']):
36+
print('..', wat_path)
37+
is_passive = '.passive.' in wat_path
38+
mem_file = wat_path + '.mem'
3939
extension_arg_map = {
4040
'.out': [],
4141
}
@@ -44,13 +44,13 @@ def test_wasm_emscripten_finalize():
4444
'.mem.out': ['--separate-data-segments', mem_file],
4545
})
4646
for ext, ext_args in extension_arg_map.items():
47-
expected_file = wast_path + ext
47+
expected_file = wat_path + ext
4848
if ext != '.out' and not os.path.exists(expected_file):
4949
continue
5050

51-
cmd = shared.WASM_EMSCRIPTEN_FINALIZE + [wast_path, '-S'] + \
51+
cmd = shared.WASM_EMSCRIPTEN_FINALIZE + [wat_path, '-S'] + \
5252
ext_args
53-
cmd += args_for_finalize(os.path.basename(wast_path))
53+
cmd += args_for_finalize(os.path.basename(wat_path))
5454
actual = support.run_command(cmd)
5555

5656
if not os.path.exists(expected_file):
@@ -61,18 +61,18 @@ def test_wasm_emscripten_finalize():
6161
if ext == '.mem.out':
6262
with open(mem_file) as mf:
6363
mem = mf.read()
64-
shared.fail_if_not_identical_to_file(mem, wast_path +
64+
shared.fail_if_not_identical_to_file(mem, wat_path +
6565
'.mem.mem')
6666
os.remove(mem_file)
6767

6868

6969
def update_lld_tests():
7070
print('\n[ updatring wasm-emscripten-finalize testcases... ]\n')
7171

72-
for wast_path in shared.get_tests(shared.get_test_dir('lld'), ['.wast']):
73-
print('..', wast_path)
74-
is_passive = '.passive.' in wast_path
75-
mem_file = wast_path + '.mem'
72+
for wat_path in shared.get_tests(shared.get_test_dir('lld'), ['.wat']):
73+
print('..', wat_path)
74+
is_passive = '.passive.' in wat_path
75+
mem_file = wat_path + '.mem'
7676
extension_arg_map = {
7777
'.out': [],
7878
}
@@ -81,12 +81,12 @@ def update_lld_tests():
8181
'.mem.out': ['--separate-data-segments', mem_file + '.mem'],
8282
})
8383
for ext, ext_args in extension_arg_map.items():
84-
out_path = wast_path + ext
84+
out_path = wat_path + ext
8585
if ext != '.out' and not os.path.exists(out_path):
8686
continue
87-
cmd = shared.WASM_EMSCRIPTEN_FINALIZE + [wast_path, '-S'] + \
87+
cmd = shared.WASM_EMSCRIPTEN_FINALIZE + [wat_path, '-S'] + \
8888
ext_args
89-
cmd += args_for_finalize(os.path.basename(wast_path))
89+
cmd += args_for_finalize(os.path.basename(wat_path))
9090
actual = support.run_command(cmd)
9191
with open(out_path, 'w') as o:
9292
o.write(actual)

src/passes/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
add_custom_command(
22
OUTPUT WasmIntrinsics.cpp
3-
COMMAND python ${PROJECT_SOURCE_DIR}/scripts/embedwast.py ${PROJECT_SOURCE_DIR}/src/passes/wasm-intrinsics.wast ${CMAKE_CURRENT_BINARY_DIR}/WasmIntrinsics.cpp
4-
DEPENDS ${PROJECT_SOURCE_DIR}/scripts/embedwast.py wasm-intrinsics.wast)
3+
COMMAND python ${PROJECT_SOURCE_DIR}/scripts/embedwat.py ${PROJECT_SOURCE_DIR}/src/passes/wasm-intrinsics.wat ${CMAKE_CURRENT_BINARY_DIR}/WasmIntrinsics.cpp
4+
DEPENDS ${PROJECT_SOURCE_DIR}/scripts/embedwat.py wasm-intrinsics.wat)
55

66
set(passes_SOURCES
77
pass.cpp
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
21
;; This file contains patterns for OptimizeInstructions. Basically, we use a DSL for the patterns,
32
;; and the DSL is just wasm itself, plus some functions with special meanings
43
;;
5-
;; This file is converted into OptimizeInstructions.wast.processed by
4+
;; This file is converted into OptimizeInstructions.wat.processed by
65
;; scripts/process_optimize_instructions.py
76
;; which makes it importable by C++. Then we just #include it there, avoiding the need to ship
87
;; a data file on the side.
@@ -24,4 +23,3 @@
2423
)
2524
)
2625
)
27-

src/passes/OptimizeInstructions.wast.processed renamed to src/passes/OptimizeInstructions.wat.processed

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
"\n"
21
";; This file contains patterns for OptimizeInstructions. Basically, we use a DSL for the patterns,\n"
32
";; and the DSL is just wasm itself, plus some functions with special meanings\n"
43
";;\n"
5-
";; This file is converted into OptimizeInstructions.wast.processed by\n"
4+
";; This file is converted into OptimizeInstructions.wat.processed by\n"
65
";; scripts/process_optimize_instructions.py\n"
76
";; which makes it importable by C++. Then we just #include it there, avoiding the need to ship\n"
87
";; a data file on the side.\n"
@@ -24,4 +23,3 @@
2423
")\n"
2524
")\n"
2625
")\n"
27-
"\n"

0 commit comments

Comments
 (0)