diff options
Diffstat (limited to 'test/unit/test_stack_ir.py')
-rw-r--r-- | test/unit/test_stack_ir.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/test/unit/test_stack_ir.py b/test/unit/test_stack_ir.py index 78086d0cc..191d7eaec 100644 --- a/test/unit/test_stack_ir.py +++ b/test/unit/test_stack_ir.py @@ -7,13 +7,16 @@ class StackIRTest(utils.BinaryenTestCase): # test that stack IR opts make a difference. def test_stack_ir_opts(self): path = self.input_path('stack_ir.wat') - opt = shared.run_process(shared.WASM_OPT + [path, '-O', '--generate-stack-ir', '--optimize-stack-ir', '--print-stack-ir', '-o', 'a.wasm'], capture_output=True).stdout - nonopt = shared.run_process(shared.WASM_OPT + [path, '-O', '--generate-stack-ir', '--print-stack-ir', '-o', 'b.wasm'], capture_output=True).stdout + shared_args = shared.WASM_OPT + [path, '--print-stack-ir'] + # optimize level 2 will only run some of the stack IR opts. level 3 does + # noticeably more. + nonopt = shared.run_process(shared_args + ['-o', 'nonopt.wasm', '--optimize-level=2'], capture_output=True).stdout + yesopt = shared.run_process(shared_args + ['-o', 'yesopt.wasm', '--optimize-level=3'], capture_output=True).stdout # see a difference in the printed stack IR (the optimizations let us # remove a pair of local.set/get) - self.assertNotEqual(opt, nonopt) - self.assertLess(len(opt), len(nonopt)) + self.assertNotEqual(yesopt, nonopt) + self.assertLess(len(yesopt), len(nonopt)) # see a difference in the actual emitted wasm binary. - opt_size = os.path.getsize('a.wasm') - nonopt_size = os.path.getsize('b.wasm') - self.assertLess(opt_size, nonopt_size) + yesopt_size = os.path.getsize('yesopt.wasm') + nonopt_size = os.path.getsize('nonopt.wasm') + self.assertLess(yesopt_size, nonopt_size) |