Skip to content

Commit b4b37c1

Browse files
authored
Remove use of -s WASM=1 from test code (#12398)
This has been the default for a long time.
1 parent 5c4a916 commit b4b37c1

File tree

4 files changed

+28
-34
lines changed

4 files changed

+28
-34
lines changed

emcc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ def filter_out_duplicate_dynamic_libs(inputs):
12651265
options.use_closure_compiler = False
12661266

12671267
if shared.Settings.WASM == 2 and shared.Settings.SINGLE_FILE:
1268-
exit_with_error('cannot have both WASM=2 and SINGLE_FILE enabled at the same time (pick either JS to target with -s WASM=0 or Wasm to target with -s WASM=1)')
1268+
exit_with_error('cannot have both WASM=2 and SINGLE_FILE enabled at the same time')
12691269

12701270
if shared.Settings.SEPARATE_DWARF and shared.Settings.WASM2JS:
12711271
exit_with_error('cannot have both SEPARATE_DWARF and WASM2JS at the same time (as there is no wasm file)')

tests/test_browser.py

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@ def test_egl_width_height_with_proxy_to_pthread(self):
15621562
def test_egl_createcontext_error(self):
15631563
self.btest('test_egl_createcontext_error.c', '1', args=['-lEGL', '-lGL'])
15641564

1565-
def do_test_worker(self, args=[]):
1565+
def test_worker(self):
15661566
# Test running in a web worker
15671567
create_test_file('file.dat', 'data for worker')
15681568
html_file = open('main.html', 'w')
@@ -1585,14 +1585,12 @@ def do_test_worker(self, args=[]):
15851585
html_file.close()
15861586

15871587
for file_data in [1, 0]:
1588-
cmd = [EMCC, path_from_root('tests', 'hello_world_worker.cpp'), '-o', 'worker.js'] + (['--preload-file', 'file.dat'] if file_data else []) + args
1588+
cmd = [EMCC, path_from_root('tests', 'hello_world_worker.cpp'), '-o', 'worker.js'] + (['--preload-file', 'file.dat'] if file_data else [])
15891589
print(cmd)
15901590
subprocess.check_call(cmd)
15911591
self.assertExists('worker.js')
15921592
self.run_browser('main.html', '', '/report_result?hello from worker, and :' + ('data for w' if file_data else '') + ':')
15931593

1594-
def test_worker(self):
1595-
self.do_test_worker()
15961594
self.assertContained('you should not see this text when in a worker!', self.run_js('worker.js')) # code should run standalone too
15971595

15981596
@no_firefox('keeps sending OPTIONS requests, and eventually errors')
@@ -2000,7 +1998,7 @@ def test_cubegeom_proc(self):
20001998
}
20011999
''')
20022000
# also test -Os in wasm, which uses meta-dce, which should not break legacy gl emulation hacks
2003-
for opts in [[], ['-O1'], ['-Os', '-s', 'WASM=1']]:
2001+
for opts in [[], ['-O1'], ['-Os']]:
20042002
self.btest('cubegeom_proc.c', reference='cubegeom.png', args=opts + ['side.c', '-s', 'LEGACY_GL_EMULATION=1', '-lGL', '-lSDL'])
20052003

20062004
@requires_graphics_hardware
@@ -2404,7 +2402,7 @@ def test_preload_module(self):
24042402
return 42;
24052403
}
24062404
''')
2407-
self.compile_btest(['library.c', '-s', 'SIDE_MODULE=1', '-O2', '-o', 'library.wasm', '-s', 'WASM=1', '-s', 'EXPORT_ALL=1'])
2405+
self.compile_btest(['library.c', '-s', 'SIDE_MODULE=1', '-O2', '-o', 'library.wasm', '-s', 'EXPORT_ALL=1'])
24082406
os.rename('library.wasm', 'library.so')
24092407
main = r'''
24102408
#include <dlfcn.h>
@@ -2435,7 +2433,7 @@ def test_preload_module(self):
24352433
'''
24362434
self.btest(
24372435
main,
2438-
args=['-s', 'MAIN_MODULE=1', '--preload-file', '.@/', '-O2', '-s', 'WASM=1', '--use-preload-plugins', '-s', 'EXPORT_ALL=1'],
2436+
args=['-s', 'MAIN_MODULE=1', '--preload-file', '.@/', '-O2', '--use-preload-plugins', '-s', 'EXPORT_ALL=1'],
24392437
expected='0')
24402438

24412439
def test_mmap_file(self):
@@ -3349,7 +3347,7 @@ def test_modularize_network_error(self):
33493347
src = open(path_from_root('tests', 'browser_test_hello_world.c')).read()
33503348
create_test_file('test.c', src)
33513349
browser_reporting_js_path = path_from_root('tests', 'browser_reporting.js')
3352-
self.compile_btest(['test.c', '-s', 'MODULARIZE=1', '-s', 'WASM=1', '-s', 'EXPORT_NAME="createModule"', '--extern-pre-js', browser_reporting_js_path])
3350+
self.compile_btest(['test.c', '-s', 'MODULARIZE=1', '-s', 'EXPORT_NAME="createModule"', '--extern-pre-js', browser_reporting_js_path])
33533351
create_test_file('a.html', '''
33543352
<script src="a.out.js"></script>
33553353
<script>
@@ -3460,16 +3458,16 @@ def test_dynamic_link(self):
34603458
create_test_file('pre.js', '''
34613459
var Module = { dynamicLibraries: ['side.wasm'] };
34623460
''')
3463-
self.run_process([EMCC, 'side.cpp', '-s', 'SIDE_MODULE=1', '-O2', '-o', 'side.wasm', '-s', 'WASM=1', '-s', 'EXPORT_ALL=1'])
3464-
self.btest(self.in_dir('main.cpp'), '2', args=['-s', 'MAIN_MODULE=1', '-O2', '--pre-js', 'pre.js', '-s', 'WASM=1', '--proxy-to-worker', '-s', 'EXPORT_ALL=1'])
3461+
self.run_process([EMCC, 'side.cpp', '-s', 'SIDE_MODULE=1', '-O2', '-o', 'side.wasm', '-s', 'EXPORT_ALL=1'])
3462+
self.btest(self.in_dir('main.cpp'), '2', args=['-s', 'MAIN_MODULE=1', '-O2', '--pre-js', 'pre.js', '--proxy-to-worker', '-s', 'EXPORT_ALL=1'])
34653463

34663464
print('wasm (will auto-preload since no sync binary reading)')
34673465

34683466
create_test_file('pre.js', '''
34693467
Module.dynamicLibraries = ['side.wasm'];
34703468
''')
34713469
# same wasm side module works
3472-
self.btest(self.in_dir('main.cpp'), '2', args=['-s', 'MAIN_MODULE=1', '-O2', '--pre-js', 'pre.js', '-s', 'WASM=1', '-s', 'EXPORT_ALL=1'])
3470+
self.btest(self.in_dir('main.cpp'), '2', args=['-s', 'MAIN_MODULE=1', '-O2', '--pre-js', 'pre.js', '-s', 'EXPORT_ALL=1'])
34733471

34743472
# verify that dynamic linking works in all kinds of in-browser environments.
34753473
# don't mix different kinds in a single test.
@@ -4087,15 +4085,12 @@ def test_manual_wasm_instantiate(self):
40874085
shutil.copyfile(path_from_root('tests', 'manual_wasm_instantiate.html'), 'manual_wasm_instantiate.html')
40884086
self.run_browser('manual_wasm_instantiate.html', 'wasm instantiation succeeded', '/report_result?1')
40894087

4090-
def test_binaryen_worker(self):
4091-
self.do_test_worker(['-s', 'WASM=1'])
4092-
40934088
def test_wasm_locate_file(self):
40944089
# Test that it is possible to define "Module.locateFile(foo)" function to locate where worker.js will be loaded from.
40954090
ensure_dir('cdn')
40964091
create_test_file('shell2.html', open(path_from_root('src', 'shell.html')).read().replace('var Module = {', 'var Module = { locateFile: function(filename) { if (filename == "test.wasm") return "cdn/test.wasm"; else return filename; }, '))
40974092
create_test_file('src.cpp', self.with_report_result(open(path_from_root('tests', 'browser_test_hello_world.c')).read()))
4098-
self.compile_btest(['src.cpp', '--shell-file', 'shell2.html', '-s', 'WASM=1', '-o', 'test.html'])
4093+
self.compile_btest(['src.cpp', '--shell-file', 'shell2.html', '-o', 'test.html'])
40994094
shutil.move('test.wasm', os.path.join('cdn', 'test.wasm'))
41004095
self.run_browser('test.html', '', '/report_result?0')
41014096

@@ -4526,7 +4521,6 @@ def test_load_js_from_blob_with_pthreads(self):
45264521

45274522
# Tests that base64 utils work in browser with no native atob function
45284523
def test_base64_atob_fallback(self):
4529-
opts = ['-s', 'SINGLE_FILE=1', '-s', 'WASM=1']
45304524
src = r'''
45314525
#include <stdio.h>
45324526
#include <emscripten.h>
@@ -4539,7 +4533,7 @@ def test_base64_atob_fallback(self):
45394533
# generate a dummy file
45404534
create_test_file('dummy_file', 'dummy')
45414535
# compile the code with the modularize feature and the preload-file option enabled
4542-
self.compile_btest(['test.c', '-s', 'MODULARIZE=1', '-s', 'EXPORT_NAME="Foo"', '--preload-file', 'dummy_file'] + opts)
4536+
self.compile_btest(['test.c', '-s', 'MODULARIZE=1', '-s', 'EXPORT_NAME="Foo"', '--preload-file', 'dummy_file', '-s', 'SINGLE_FILE=1'])
45434537
create_test_file('a.html', '''
45444538
<script>
45454539
atob = undefined;
@@ -4554,7 +4548,7 @@ def test_base64_atob_fallback(self):
45544548

45554549
# Tests that SINGLE_FILE works as intended in generated HTML (with and without Worker)
45564550
def test_single_file_html(self):
4557-
self.btest('single_file_static_initializer.cpp', '19', args=['-s', 'SINGLE_FILE=1', '-s', 'WASM=1'], also_proxied=True)
4551+
self.btest('single_file_static_initializer.cpp', '19', args=['-s', 'SINGLE_FILE=1'], also_proxied=True)
45584552
self.assertExists('test.html')
45594553
self.assertNotExists('test.js')
45604554
self.assertNotExists('test.worker.js')
@@ -4585,8 +4579,8 @@ def test_single_file_locate_file(self):
45854579
for wasm_enabled in [True, False]:
45864580
args = ['src.cpp', '-o', 'test.js', '-s', 'SINGLE_FILE=1']
45874581

4588-
if wasm_enabled:
4589-
args += ['-s', 'WASM=1']
4582+
if not wasm_enabled:
4583+
args += ['-s', 'WASM=0']
45904584

45914585
self.compile_btest(args)
45924586

@@ -4610,7 +4604,7 @@ def test_single_file_locate_file(self):
46104604
# Tests that SINGLE_FILE works as intended in a Worker in JS output
46114605
def test_single_file_worker_js(self):
46124606
create_test_file('src.cpp', self.with_report_result(open(path_from_root('tests', 'browser_test_hello_world.c')).read()))
4613-
self.compile_btest(['src.cpp', '-o', 'test.js', '--proxy-to-worker', '-s', 'SINGLE_FILE=1', '-s', 'WASM=1'])
4607+
self.compile_btest(['src.cpp', '-o', 'test.js', '--proxy-to-worker', '-s', 'SINGLE_FILE=1'])
46144608
create_test_file('test.html', '<script src="test.js"></script>')
46154609
self.run_browser('test.html', None, '/report_result?0')
46164610
self.assertExists('test.js')
@@ -4634,12 +4628,12 @@ def test_pthreads_started_in_worker(self):
46344628
def test_access_file_after_heap_resize(self):
46354629
create_test_file('test.txt', 'hello from file')
46364630
create_test_file('page.c', self.with_report_result(open(path_from_root('tests', 'access_file_after_heap_resize.c'), 'r').read()))
4637-
self.compile_btest(['page.c', '-s', 'WASM=1', '-s', 'ALLOW_MEMORY_GROWTH=1', '--preload-file', 'test.txt', '-o', 'page.html'])
4631+
self.compile_btest(['page.c', '-s', 'ALLOW_MEMORY_GROWTH=1', '--preload-file', 'test.txt', '-o', 'page.html'])
46384632
self.run_browser('page.html', 'hello from file', '/report_result?15')
46394633

46404634
# with separate file packager invocation
46414635
self.run_process([PYTHON, FILE_PACKAGER, 'data.js', '--preload', 'test.txt', '--js-output=' + 'data.js'])
4642-
self.compile_btest(['page.c', '-s', 'WASM=1', '-s', 'ALLOW_MEMORY_GROWTH=1', '--pre-js', 'data.js', '-o', 'page.html', '-s', 'FORCE_FILESYSTEM=1'])
4636+
self.compile_btest(['page.c', '-s', 'ALLOW_MEMORY_GROWTH=1', '--pre-js', 'data.js', '-o', 'page.html', '-s', 'FORCE_FILESYSTEM=1'])
46434637
self.run_browser('page.html', 'hello from file', '/report_result?15')
46444638

46454639
def test_unicode_html_shell(self):

tests/test_other.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6429,7 +6429,7 @@ def test_binaryen_mem(self):
64296429
(['-s', 'INITIAL_MEMORY=20971520', '-s', 'MAXIMUM_MEMORY=41943040'], 320, 640),
64306430
(['-s', 'INITIAL_MEMORY=20971520', '-s', 'ALLOW_MEMORY_GROWTH=1', '-s', 'MAXIMUM_MEMORY=41943040'], 320, 640),
64316431
]:
6432-
cmd = [EMCC, path_from_root('tests', 'hello_world.c'), '-s', 'WASM=1', '-O2'] + args
6432+
cmd = [EMCC, path_from_root('tests', 'hello_world.c'), '-O2'] + args
64336433
print(' '.join(cmd))
64346434
self.run_process(cmd)
64356435
wat = self.run_process([wasm_dis, 'a.out.wasm'], stdout=PIPE).stdout
@@ -6484,7 +6484,7 @@ def test_binaryen_ctors(self):
64846484
correct = self.run_js('a.out.js')
64856485
for args in [[], ['-s', 'RELOCATABLE=1']]:
64866486
print(args)
6487-
self.run_process([EMCC, 'src.cpp', '-s', 'WASM=1', '-o', 'b.out.js'] + args)
6487+
self.run_process([EMCC, 'src.cpp', '-o', 'b.out.js'] + args)
64886488
seen = self.run_js('b.out.js')
64896489
assert correct == seen, correct + '\n vs \n' + seen
64906490

@@ -6522,7 +6522,7 @@ def test_binaryen_ignore_implicit_traps(self):
65226522
(['-s', 'BINARYEN_IGNORE_IMPLICIT_TRAPS=1'], True),
65236523
]:
65246524
print(args, expect)
6525-
cmd = [EMCC, path_from_root('tests', 'hello_libcxx.cpp'), '-s', 'WASM=1', '-O3'] + args
6525+
cmd = [EMCC, path_from_root('tests', 'hello_libcxx.cpp'), '-O3'] + args
65266526
print(' '.join(cmd))
65276527
err = self.run_process(cmd, stdout=PIPE, stderr=PIPE).stderr
65286528
self.assertContainedIf('--ignore-implicit-traps ', err, expect)
@@ -6738,7 +6738,7 @@ def test_metadce_libcxxabi_message(self, filename, *args):
67386738
# ensures runtime exports work, even with metadce
67396739
def test_extra_runtime_exports(self):
67406740
exports = ['stackSave', 'stackRestore', 'stackAlloc', 'FS']
6741-
self.run_process([EMCC, path_from_root('tests', 'hello_world.cpp'), '-s', 'WASM=1', '-Os', '-s', 'EXTRA_EXPORTED_RUNTIME_METHODS=%s' % str(exports)])
6741+
self.run_process([EMCC, path_from_root('tests', 'hello_world.cpp'), '-Os', '-s', 'EXTRA_EXPORTED_RUNTIME_METHODS=%s' % str(exports)])
67426742
js = open('a.out.js').read()
67436743
for export in exports:
67446744
assert ('Module["%s"]' % export) in js, export
@@ -7996,7 +7996,7 @@ def check_size(f, expected_size):
79967996
self.assertLess(obtained_size, expected_size)
79977997

79987998
self.run_process([PYTHON, path_from_root('tests', 'gen_many_js_functions.py'), 'library_long.js', 'main_long.c'])
7999-
for wasm in [['-s', 'WASM=1'], ['-s', 'WASM=0']]:
7999+
for wasm in [[], ['-s', 'WASM=0']]:
80008000
# Currently we rely on Closure for full minification of every appearance of JS function names.
80018001
# TODO: Add minification also for non-Closure users and add [] to this list to test minification without Closure.
80028002
for closure in [['--closure', '1']]:
@@ -8067,8 +8067,8 @@ def test_emscripten_license(self, expect_license, args):
80678067
# access from calling code, and should not have the unminified name exist more than once, that
80688068
# would be wasteful for size)
80698069
def test_function_exports_are_small(self):
8070-
def test(wasm, closure, opt):
8071-
extra_args = wasm + opt + closure
8070+
def test(args, closure, opt):
8071+
extra_args = args + opt + closure
80728072
print(extra_args)
80738073
args = [EMCC, path_from_root('tests', 'long_function_name_in_export.c'), '-o', 'a.html', '-s', 'ENVIRONMENT=web', '-s', 'DECLARE_ASM_MODULE_EXPORTS=0', '-Werror'] + extra_args
80748074
self.run_process(args)
@@ -8079,14 +8079,14 @@ def test(wasm, closure, opt):
80798079

80808080
# TODO: Add stricter testing when Wasm side is also optimized: (currently Wasm does still need
80818081
# to reference exports multiple times)
8082-
if 'WASM=1' not in wasm:
8082+
if 'WASM=0' in args:
80838083
num_times_export_is_referenced = output.count('thisIsAFunctionExportedFromAsmJsOrWasmWithVeryLongFunction')
80848084
self.assertEqual(num_times_export_is_referenced, 1)
80858085

80868086
for closure in [[], ['--closure', '1']]:
80878087
for opt in [['-O2'], ['-O3'], ['-Os']]:
80888088
test(['-s', 'WASM=0'], closure, opt)
8089-
test(['-s', 'WASM=1', '-s', 'WASM_ASYNC_COMPILATION=0'], closure, opt)
8089+
test(['-s', 'WASM_ASYNC_COMPILATION=0'], closure, opt)
80908090

80918091
def test_minimal_runtime_code_size(self):
80928092
smallest_code_size_args = ['-s', 'MINIMAL_RUNTIME=2',

tools/determinism_checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
def run():
16-
subprocess.check_call(['emcc', 'src.cpp', '-O2', '-s', 'WASM=1'])
16+
subprocess.check_call(['emcc', 'src.cpp', '-O2'])
1717
ret = {}
1818
for relevant_file in os.listdir('.'):
1919
ret[relevant_file] = open(relevant_file).read()

0 commit comments

Comments
 (0)