@sync
def test_webidl(self):
    if (self.run_name == 'asm2'):
        self.emcc_args += ['--closure', '1', '-g1']
        self.set_setting('MODULARIZE', 1)

    def do_test_in_mode(mode, allow_memory_growth):
        print('testing mode', mode, ', memory growth =', allow_memory_growth)
        os.environ['IDL_CHECKS'] = mode
        run_process([PYTHON, path_from_root('tools', 'webidl_binder.py'), path_from_root('tests', 'webidl', 'test.idl'), 'glue'])
        self.assertExists('glue.cpp')
        self.assertExists('glue.js')
        create_test_file('export.js', '\n// test purposes: remove printErr output, whose order is unpredictable when compared to print\nerr = err = function(){};\n')
        self.emcc_args += ['-s', 'EXPORTED_FUNCTIONS=["_malloc"]', '--post-js', 'glue.js', '--post-js', 'export.js']
        if allow_memory_growth:
            self.emcc_args += ['-s', 'ALLOW_MEMORY_GROWTH', '-Wno-almost-asm']
        shutil.copyfile(path_from_root('tests', 'webidl', 'test.h'), 'test.h')
        shutil.copyfile(path_from_root('tests', 'webidl', 'test.cpp'), 'test.cpp')
        src = open('test.cpp').read()

        def post(filename):
            with open(filename, 'a') as f:
                f.write('\n\n')
                if (self.run_name == 'asm2'):
                    f.write('var TheModule = Module();\n')
                else:
                    f.write('var TheModule = Module;\n')
                f.write('\n\n')
                if allow_memory_growth:
                    f.write('var isMemoryGrowthAllowed = true;')
                else:
                    f.write('var isMemoryGrowthAllowed = false;')
                f.write(open(path_from_root('tests', 'webidl', 'post.js')).read())
                f.write('\n\n')
        output = open(path_from_root('tests', 'webidl', ('output_%s.txt' % mode))).read()
        self.do_run(src, output, post_build=post, output_nicerizer=(lambda out, err: out))
    do_test_in_mode('ALL', False)
    do_test_in_mode('FAST', False)
    do_test_in_mode('DEFAULT', False)
    do_test_in_mode('ALL', True)
@sync
def test_webidl(self):
    if (self.run_name == 'asm2'):
        self.emcc_args += ['--closure', '1', '-g1']
        self.set_setting('MODULARIZE', 1)

    def do_test_in_mode(mode, allow_memory_growth):
        print('testing mode', mode, ', memory growth =', allow_memory_growth)
        os.environ['IDL_CHECKS'] = mode
        run_process([PYTHON, path_from_root('tools', 'webidl_binder.py'), path_from_root('tests', 'webidl', 'test.idl'), 'glue'])
        self.assertExists('glue.cpp')
        self.assertExists('glue.js')
        create_test_file('export.js', '\n// test purposes: remove printErr output, whose order is unpredictable when compared to print\nerr = err = function(){};\n')
        self.emcc_args += ['-s', 'EXPORTED_FUNCTIONS=["_malloc"]', '--post-js', 'glue.js', '--post-js', 'export.js']
        if allow_memory_growth:
            self.emcc_args += ['-s', 'ALLOW_MEMORY_GROWTH', '-Wno-almost-asm']
        shutil.copyfile(path_from_root('tests', 'webidl', 'test.h'), 'test.h')
        shutil.copyfile(path_from_root('tests', 'webidl', 'test.cpp'), 'test.cpp')
        src = open('test.cpp').read()

        def post(filename):
            with open(filename, 'a') as f:
                f.write('\n\n')
                if (self.run_name == 'asm2'):
                    f.write('var TheModule = Module();\n')
                else:
                    f.write('var TheModule = Module;\n')
                f.write('\n\n')
                if allow_memory_growth:
                    f.write('var isMemoryGrowthAllowed = true;')
                else:
                    f.write('var isMemoryGrowthAllowed = false;')
                f.write(open(path_from_root('tests', 'webidl', 'post.js')).read())
                f.write('\n\n')
        output = open(path_from_root('tests', 'webidl', ('output_%s.txt' % mode))).read()
        self.do_run(src, output, post_build=post, output_nicerizer=(lambda out, err: out))
    do_test_in_mode('ALL', False)
    do_test_in_mode('FAST', False)
    do_test_in_mode('DEFAULT', False)
    do_test_in_mode('ALL', True)