Skip to content

Commit ca0d691

Browse files
authored
[test] Add codesize test for -sSINGLE_FILE. NFC (#23962)
This is part of the fix for #23938
1 parent 7432ccb commit ca0d691

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3826
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
12217

Diff for: test/test_other.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -9081,18 +9081,24 @@ def run_codesize_test(self, filename, args=[], expected_exists=[], expected_not_
90819081
for not_exists in expected_not_exists:
90829082
self.assertNotIn(not_exists, sent)
90839083

9084-
# measure the wasm size without the name section
9085-
building.strip('a.out.wasm', 'a.out.nodebug.wasm', sections=['name'])
9086-
wasm_size = os.path.getsize('a.out.nodebug.wasm')
9087-
size_file = expected_basename + '.size'
90889084
js_size = os.path.getsize('a.out.js')
90899085
gz_size = get_file_gzipped_size('a.out.js')
90909086
js_size_file = expected_basename + '.jssize'
90919087
gz_size_file = expected_basename + '.gzsize'
9092-
self.check_expected_size_in_file('wasm', size_file, wasm_size)
90939088
self.check_expected_size_in_file('js', js_size_file, js_size)
90949089
self.check_expected_size_in_file('gz', gz_size_file, gz_size)
90959090

9091+
if '-sSINGLE_FILE' in args:
9092+
# No wasm file in the final output so we skip the rest of the
9093+
# testing
9094+
return
9095+
9096+
# measure the wasm size without the name section
9097+
building.strip('a.out.wasm', 'a.out.nodebug.wasm', sections=['name'])
9098+
wasm_size = os.path.getsize('a.out.nodebug.wasm')
9099+
size_file = expected_basename + '.size'
9100+
self.check_expected_size_in_file('wasm', size_file, wasm_size)
9101+
90969102
imports, exports, funcs = self.parse_wasm('a.out.wasm')
90979103
# Deminify the imports/export lists, if minification occured
90989104
if os.path.exists('minify.map'):
@@ -9189,14 +9195,14 @@ def test_codesize_cxx(self, *args):
91899195
'Os': (['-Os'], [], []),
91909196
'Oz': (['-Oz'], [], []),
91919197
# finally, check what happens when we export nothing. wasm should be almost empty
9192-
'export_nothing':
9193-
(['-Os', '-sEXPORTED_FUNCTIONS=[]'], [], []), # noqa
9198+
'export_nothing': (['-Os', '-sEXPORTED_FUNCTIONS=[]'], [], []),
91949199
# we don't metadce with linkable code! other modules may want stuff
91959200
# TODO(sbc): Investivate why the number of exports is order of magnitude
91969201
# larger for wasm backend.
9197-
'dylink': (['-O3', '-sMAIN_MODULE=2'], [], []), # noqa
9202+
'dylink': (['-O3', '-sMAIN_MODULE=2'], [], []),
91989203
# WasmFS should not be fully linked into a hello world program.
9199-
'wasmfs': (['-O3', '-sWASMFS'], [], []), # noqa
9204+
'wasmfs': (['-O3', '-sWASMFS'], [], []),
9205+
'single_file': (['-O3', '-sSINGLE_FILE'], [], []), # noqa
92009206
})
92019207
def test_codesize_hello(self, *args):
92029208
self.run_codesize_test('hello_world.c', *args)

0 commit comments

Comments
 (0)