Skip to content

Extend test_exceptions_allowed to include wasm. NFC #13734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,9 @@ def test_exceptions_allowed(self):
self.set_setting('INLINING_LIMIT', 50)

self.do_core_test('test_exceptions_allowed.cpp')
size = len(open('test_exceptions_allowed.js').read())
size = os.path.getsize('test_exceptions_allowed.js')
if self.is_wasm():
size += os.path.getsize('test_exceptions_allowed.wasm')
shutil.copyfile('test_exceptions_allowed.js', 'orig.js')

# check that an empty allow list works properly (as in, same as exceptions disabled)
Expand All @@ -1253,26 +1255,34 @@ def test_exceptions_allowed(self):

self.set_setting('EXCEPTION_CATCHING_ALLOWED', [])
self.do_run_from_file(src, empty_output, assert_returncode=NON_ZERO)
empty_size = len(open('test_exceptions_allowed.js').read())
empty_size = os.path.getsize('test_exceptions_allowed.js')
if self.is_wasm():
empty_size += os.path.getsize('test_exceptions_allowed.wasm')
shutil.copyfile('test_exceptions_allowed.js', 'empty.js')

self.set_setting('EXCEPTION_CATCHING_ALLOWED', ['fake'])
self.do_run_from_file(src, empty_output, assert_returncode=NON_ZERO)
fake_size = len(open('test_exceptions_allowed.js').read())
fake_size = os.path.getsize('test_exceptions_allowed.js')
if self.is_wasm():
fake_size += os.path.getsize('test_exceptions_allowed.wasm')
shutil.copyfile('test_exceptions_allowed.js', 'fake.js')

self.set_setting('DISABLE_EXCEPTION_CATCHING')
self.do_run_from_file(src, empty_output, assert_returncode=NON_ZERO)
disabled_size = len(open('test_exceptions_allowed.js').read())
disabled_size = os.path.getsize('test_exceptions_allowed.js')
if self.is_wasm():
disabled_size += os.path.getsize('test_exceptions_allowed.wasm')
shutil.copyfile('test_exceptions_allowed.js', 'disabled.js')

if not self.is_wasm():
print(size, empty_size, fake_size, disabled_size)
assert empty_size == fake_size, [empty_size, fake_size]
# big change when we disable exception catching of the function
assert size - empty_size > 0.01 * size, [empty_size, size]
# full disable can remove a little bit more
assert empty_size >= disabled_size, [empty_size, disabled_size]
print('size: %d' % size)
print('empty_size: %d' % empty_size)
print('fake_size: %d' % fake_size)
print('disabled_size: %d' % disabled_size)
self.assertEqual(empty_size, fake_size)
# big change when we disable exception catching of the function
self.assertGreater(size - empty_size, 0.01 * size)
# full disable can remove a little bit more
self.assertLess(disabled_size, empty_size)

def test_exceptions_allowed_2(self):
self.set_setting('DISABLE_EXCEPTION_CATCHING', 2)
Expand Down