Skip to content

Commit a8d325c

Browse files
authored
Rebaseline test_small_js_flags. NFC (#23156)
Also convert to `check_expected_size_in_file` which allows this test to be updated via `--rebaseline` This change shows the incremental progress we've been making on code size recently!
1 parent 1092ec3 commit a8d325c

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4369

test/common.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,6 +1537,16 @@ def assertBinaryEqual(self, file1, file2):
15371537
self.assertEqual(read_binary(file1),
15381538
read_binary(file2))
15391539

1540+
def check_expected_size_in_file(self, desc, filename, size):
1541+
if EMTEST_REBASELINE:
1542+
create_file(filename, f'{size}\n', absolute=True)
1543+
size_slack = 0.05
1544+
expected_size = int(read_file(filename).strip())
1545+
delta = size - expected_size
1546+
ratio = abs(delta) / float(expected_size)
1547+
print(' seen %s size: %d (expected: %d) (delta: %d), ratio to expected: %f' % (desc, size, expected_size, delta, ratio))
1548+
self.assertLess(ratio, size_slack)
1549+
15401550
library_cache: Dict[str, Tuple[str, object]] = {}
15411551

15421552
def get_build_dir(self):

test/test_browser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4204,7 +4204,9 @@ def test_small_js_flags(self):
42044204
print('size:', size)
42054205
# Note that this size includes test harness additions (for reporting the result, etc.).
42064206
if not self.is_wasm64() and not self.is_2gb():
4207-
self.assertLess(abs(size - 4477), 100)
4207+
self.check_expected_size_in_file('js',
4208+
test_file('browser/test_small_js_flags.js.size'),
4209+
size)
42084210

42094211
# Tests that it is possible to initialize and render WebGL content in a
42104212
# pthread by using OffscreenCanvas.

test/test_other.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8712,16 +8712,6 @@ def build(args):
87128712
# adding --metrics should not affect code size
87138713
self.assertEqual(base_size, os.path.getsize('a.out.wasm'))
87148714

8715-
def check_expected_size_in_file(self, desc, filename, size):
8716-
if common.EMTEST_REBASELINE:
8717-
create_file(filename, f'{size}\n', absolute=True)
8718-
size_slack = 0.05
8719-
expected_size = int(read_file(filename).strip())
8720-
delta = size - expected_size
8721-
ratio = abs(delta) / float(expected_size)
8722-
print(' seen %s size: %d (expected: %d) (delta: %d), ratio to expected: %f' % (desc, size, expected_size, delta, ratio))
8723-
self.assertLess(ratio, size_slack)
8724-
87258715
@crossplatform
87268716
def test_unoptimized_code_size(self):
87278717
# We don't care too about unoptimized code size but we would like to keep it

0 commit comments

Comments
 (0)