Skip to content

Commit c470514

Browse files
authored
Extend test_exceptions_allowed to include wasm. NFC (#13734)
Parts of the test were previously disabled under wasm but it turns out the assertions all hold under wasm too.
1 parent ebf0c5f commit c470514

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

tests/test_core.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,9 @@ def test_exceptions_allowed(self):
12441244
self.set_setting('INLINING_LIMIT', 50)
12451245

12461246
self.do_core_test('test_exceptions_allowed.cpp')
1247-
size = len(open('test_exceptions_allowed.js').read())
1247+
size = os.path.getsize('test_exceptions_allowed.js')
1248+
if self.is_wasm():
1249+
size += os.path.getsize('test_exceptions_allowed.wasm')
12481250
shutil.copyfile('test_exceptions_allowed.js', 'orig.js')
12491251

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

12541256
self.set_setting('EXCEPTION_CATCHING_ALLOWED', [])
12551257
self.do_run_from_file(src, empty_output, assert_returncode=NON_ZERO)
1256-
empty_size = len(open('test_exceptions_allowed.js').read())
1258+
empty_size = os.path.getsize('test_exceptions_allowed.js')
1259+
if self.is_wasm():
1260+
empty_size += os.path.getsize('test_exceptions_allowed.wasm')
12571261
shutil.copyfile('test_exceptions_allowed.js', 'empty.js')
12581262

12591263
self.set_setting('EXCEPTION_CATCHING_ALLOWED', ['fake'])
12601264
self.do_run_from_file(src, empty_output, assert_returncode=NON_ZERO)
1261-
fake_size = len(open('test_exceptions_allowed.js').read())
1265+
fake_size = os.path.getsize('test_exceptions_allowed.js')
1266+
if self.is_wasm():
1267+
fake_size += os.path.getsize('test_exceptions_allowed.wasm')
12621268
shutil.copyfile('test_exceptions_allowed.js', 'fake.js')
12631269

12641270
self.set_setting('DISABLE_EXCEPTION_CATCHING')
12651271
self.do_run_from_file(src, empty_output, assert_returncode=NON_ZERO)
1266-
disabled_size = len(open('test_exceptions_allowed.js').read())
1272+
disabled_size = os.path.getsize('test_exceptions_allowed.js')
1273+
if self.is_wasm():
1274+
disabled_size += os.path.getsize('test_exceptions_allowed.wasm')
12671275
shutil.copyfile('test_exceptions_allowed.js', 'disabled.js')
12681276

1269-
if not self.is_wasm():
1270-
print(size, empty_size, fake_size, disabled_size)
1271-
assert empty_size == fake_size, [empty_size, fake_size]
1272-
# big change when we disable exception catching of the function
1273-
assert size - empty_size > 0.01 * size, [empty_size, size]
1274-
# full disable can remove a little bit more
1275-
assert empty_size >= disabled_size, [empty_size, disabled_size]
1277+
print('size: %d' % size)
1278+
print('empty_size: %d' % empty_size)
1279+
print('fake_size: %d' % fake_size)
1280+
print('disabled_size: %d' % disabled_size)
1281+
self.assertEqual(empty_size, fake_size)
1282+
# big change when we disable exception catching of the function
1283+
self.assertGreater(size - empty_size, 0.01 * size)
1284+
# full disable can remove a little bit more
1285+
self.assertLess(disabled_size, empty_size)
12761286

12771287
def test_exceptions_allowed_2(self):
12781288
self.set_setting('DISABLE_EXCEPTION_CATCHING', 2)

0 commit comments

Comments
 (0)