diff --git a/test/browser/test_small_js_flags.js.size b/test/browser/test_small_js_flags.js.size new file mode 100644 index 0000000000000..950a0fae39f86 --- /dev/null +++ b/test/browser/test_small_js_flags.js.size @@ -0,0 +1 @@ +4369 diff --git a/test/common.py b/test/common.py index b6e958af77107..ecb50a93f243a 100644 --- a/test/common.py +++ b/test/common.py @@ -1537,6 +1537,16 @@ def assertBinaryEqual(self, file1, file2): self.assertEqual(read_binary(file1), read_binary(file2)) + def check_expected_size_in_file(self, desc, filename, size): + if EMTEST_REBASELINE: + create_file(filename, f'{size}\n', absolute=True) + size_slack = 0.05 + expected_size = int(read_file(filename).strip()) + delta = size - expected_size + ratio = abs(delta) / float(expected_size) + print(' seen %s size: %d (expected: %d) (delta: %d), ratio to expected: %f' % (desc, size, expected_size, delta, ratio)) + self.assertLess(ratio, size_slack) + library_cache: Dict[str, Tuple[str, object]] = {} def get_build_dir(self): diff --git a/test/test_browser.py b/test/test_browser.py index 135e69d0203b8..04d3353faf1bc 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -4204,7 +4204,9 @@ def test_small_js_flags(self): print('size:', size) # Note that this size includes test harness additions (for reporting the result, etc.). if not self.is_wasm64() and not self.is_2gb(): - self.assertLess(abs(size - 4477), 100) + self.check_expected_size_in_file('js', + test_file('browser/test_small_js_flags.js.size'), + size) # Tests that it is possible to initialize and render WebGL content in a # pthread by using OffscreenCanvas. diff --git a/test/test_other.py b/test/test_other.py index c1ec01d9177e3..940349ba6f881 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -8712,16 +8712,6 @@ def build(args): # adding --metrics should not affect code size self.assertEqual(base_size, os.path.getsize('a.out.wasm')) - def check_expected_size_in_file(self, desc, filename, size): - if common.EMTEST_REBASELINE: - create_file(filename, f'{size}\n', absolute=True) - size_slack = 0.05 - expected_size = int(read_file(filename).strip()) - delta = size - expected_size - ratio = abs(delta) / float(expected_size) - print(' seen %s size: %d (expected: %d) (delta: %d), ratio to expected: %f' % (desc, size, expected_size, delta, ratio)) - self.assertLess(ratio, size_slack) - @crossplatform def test_unoptimized_code_size(self): # We don't care too about unoptimized code size but we would like to keep it