diff --git a/test/common.py b/test/common.py index 521d7ba07100e..9f26339fd4d6d 100644 --- a/test/common.py +++ b/test/common.py @@ -1722,7 +1722,7 @@ def ccshared(src, linkto=None): 'a: loaded\na: b (prev: (null))\na: c (prev: b)\n', emcc_args=extra_args) extra_args = [] - for libname in ['liba', 'libb', 'libc']: + for libname in ('liba', 'libb', 'libc'): extra_args += ['--embed-file', libname + so] do_run(r''' #include diff --git a/test/test_browser.py b/test/test_browser.py index bd3729447e89e..e4254daa624c4 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -1397,7 +1397,7 @@ def test_separate_metadata_later(self): def test_idbstore(self): secret = str(time.time()) - for stage in [0, 1, 2, 3, 0, 1, 2, 0, 0, 1, 4, 2, 5, 0, 4, 6, 5]: + for stage in (0, 1, 2, 3, 0, 1, 2, 0, 0, 1, 4, 2, 5, 0, 4, 6, 5): print(stage) self.btest_exit('test_idbstore.c', args=['-lidbstore.js', f'-DSTAGE={stage}', f'-DSECRET="{secret}"'], @@ -1552,7 +1552,7 @@ def test_worker(self): ''' % self.port) - for file_data in [1, 0]: + for file_data in (1, 0): cmd = [EMCC, test_file('hello_world_worker.cpp'), '-o', 'worker.js'] + self.get_emcc_args() if file_data: cmd += ['--preload-file', 'file.dat'] @@ -2565,7 +2565,7 @@ def test_html5_special_event_targets(self): @requires_graphics_hardware def test_html5_webgl_destroy_context(self): - for opts in [[], ['-O2', '-g1'], ['-sFULL_ES2']]: + for opts in ([], ['-O2', '-g1'], ['-sFULL_ES2']): print(opts) self.btest_exit('webgl_destroy_context.cpp', args=opts + ['--shell-file', test_file('browser/webgl_destroy_context_shell.html'), '-lGL']) @@ -2576,7 +2576,7 @@ def test_webgl_context_params(self): # Test for PR#5373 (https://github.com/emscripten-core/emscripten/pull/5373) @requires_graphics_hardware def test_webgl_shader_source_length(self): - for opts in [[], ['-sFULL_ES2']]: + for opts in ([], ['-sFULL_ES2']): print(opts) self.btest_exit('webgl_shader_source_length.cpp', args=opts + ['-lGL']) @@ -2793,7 +2793,7 @@ def test_glfw3_default_hints(self): 'gl_es': (['-DCLIENT_API=GLFW_OPENGL_ES_API', '-sGL_ENABLE_GET_PROC_ADDRESS'],) }) def test_glfw3(self, args): - for opts in [[], ['-sLEGACY_GL_EMULATION'], ['-Os', '--closure=1']]: + for opts in ([], ['-sLEGACY_GL_EMULATION'], ['-Os', '--closure=1']): print(opts) self.btest('test_glfw3.c', args=['-sUSE_GLFW=3', '-lglfw', '-lGL'] + args + opts, expected='1') @@ -3160,7 +3160,7 @@ def test_async(self, args): if is_jspi(args) and not is_chrome(): self.skipTest(f'Current browser ({EMTEST_BROWSER}) does not support JSPI. Only chromium-based browsers ({CHROMIUM_BASED_BROWSERS}) support JSPI today.') - for opts in [0, 1, 2, 3]: + for opts in (0, 1, 2, 3): print(opts) self.btest_exit('async.cpp', args=['-O' + str(opts), '-g2'] + args) @@ -3332,7 +3332,7 @@ def test_modularize_and_preload_files(self): self.ldflags.append('-Wno-error=closure') # amount of memory different from the default one that will be allocated for the emscripten heap totalMemory = 33554432 - for opts in [[], ['-O1'], ['-O2', '-profiling'], ['-O2'], ['-O2', '--closure=1']]: + for opts in ([], ['-O1'], ['-O2', '-profiling'], ['-O2'], ['-O2', '--closure=1']): # the main function simply checks that the amount of allocated heap memory is correct create_file('test.c', r''' #include @@ -3605,7 +3605,7 @@ def test_pthread_64bit_atomics(self): 'O3': (['-O3'],) }) def test_pthread_64bit_cxx11_atomics(self, opt): - for pthreads in [[], ['-pthread']]: + for pthreads in ([], ['-pthread']): self.btest_exit('pthread/test_pthread_64bit_cxx11_atomics.cpp', args=opt + pthreads) # Test c++ std::thread::hardware_concurrency() @@ -3686,7 +3686,7 @@ def test_pthread_gcc_atomics(self): # Test the __sync_lock_test_and_set and __sync_lock_release primitives. @also_with_wasm2js def test_pthread_gcc_spinlock(self): - for arg in [[], ['-DUSE_EMSCRIPTEN_INTRINSICS']]: + for arg in ([], ['-DUSE_EMSCRIPTEN_INTRINSICS']): self.btest_exit('pthread/test_pthread_gcc_spinlock.cpp', args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8'] + arg) @parameterized({ @@ -3715,7 +3715,7 @@ def test_pthread_proxy_to_pthread(self): # Test that a pthread can spawn another pthread of its own. def test_pthread_create_pthread(self): - for modularize in [[], ['-sMODULARIZE', '-sEXPORT_NAME=MyModule', '--shell-file', test_file('shell_that_launches_modularize.html')]]: + for modularize in ([], ['-sMODULARIZE', '-sEXPORT_NAME=MyModule', '--shell-file', test_file('shell_that_launches_modularize.html')]): self.btest_exit('pthread/test_pthread_create_pthread.c', args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE=2'] + modularize) # Test another case of pthreads spawning pthreads, but this time the callers immediately join on the threads they created. @@ -3855,7 +3855,7 @@ def test_pthread_sbrk(self, args): 'mt': (['-pthread'],), }) def test_pthread_gauge_available_memory(self, args): - for opts in [[], ['-O2']]: + for opts in ([], ['-O2']): self.btest('gauge_available_memory.cpp', expected='1', args=['-sABORTING_MALLOC=0'] + args + opts) # Test that the proxying operations of user code from pthreads to main thread @@ -3889,7 +3889,7 @@ def test_pthread_call_async_on_main_thread(self): # Tests that spawning a new thread does not cause a reinitialization of the # global data section of the application memory area. def test_pthread_global_data_initialization(self): - for args in [['-sMODULARIZE', '-sEXPORT_NAME=MyModule', '--shell-file', test_file('shell_that_launches_modularize.html')], ['-O3']]: + for args in (['-sMODULARIZE', '-sEXPORT_NAME=MyModule', '--shell-file', test_file('shell_that_launches_modularize.html')], ['-O3']): self.btest_exit('pthread/test_pthread_global_data_initialization.c', args=args + ['-pthread', '-sPROXY_TO_PTHREAD', '-sPTHREAD_POOL_SIZE']) @requires_wasm2js @@ -4024,7 +4024,7 @@ def test_custom_messages_proxy(self): self.btest('custom_messages_proxy.c', expected='1', args=['--proxy-to-worker', '--shell-file', test_file('custom_messages_proxy_shell.html'), '--post-js', test_file('custom_messages_proxy_postjs.js')]) def test_vanilla_html_when_proxying(self): - for opts in [0, 1, 2]: + for opts in (0, 1, 2): print(opts) self.compile_btest('browser_test_hello_world.c', ['-o', 'test.js', '-O' + str(opts), '--proxy-to-worker']) create_file('test.html', '') @@ -4205,8 +4205,8 @@ def test_webgl_multi_draw(self, args): # Also there is a known bug with Mac Intel baseInstance which can fail producing the expected image result. @requires_graphics_hardware def test_webgl_draw_base_vertex_base_instance(self): - for multiDraw in [0, 1]: - for drawElements in [0, 1]: + for multiDraw in (0, 1): + for drawElements in (0, 1): self.reftest('webgl_draw_base_vertex_base_instance_test.c', 'webgl_draw_instanced_base_vertex_base_instance.png', args=['-lGL', '-sMAX_WEBGL_VERSION=2', @@ -4389,7 +4389,7 @@ def test_fetch_to_memory(self): # Test the positive case when the file URL exists. (http 200) shutil.copyfile(test_file('gears.png'), 'gears.png') - for arg in [[], ['-sFETCH_SUPPORT_INDEXEDDB=0']]: + for arg in ([], ['-sFETCH_SUPPORT_INDEXEDDB=0']): self.btest_exit('fetch/test_fetch_to_memory.cpp', args=['-sFETCH_DEBUG', '-sFETCH'] + arg) @@ -4961,7 +4961,7 @@ def test_wasm_worker_futex_wait(self, args): # Tests Wasm Worker thread stack setup @also_with_minimal_runtime def test_wasm_worker_thread_stack(self): - for mode in [0, 1, 2]: + for mode in (0, 1, 2): self.btest('wasm_worker/thread_stack.c', expected='0', args=['-sWASM_WORKERS', f'-sSTACK_OVERFLOW_CHECK={mode}']) # Tests emscripten_malloc_wasm_worker() and emscripten_current_thread_is_wasm_worker() functions diff --git a/test/test_core.py b/test/test_core.py index 27f14015b4032..ae1148d51d284 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -876,7 +876,7 @@ def test_longjmp_with_and_without_exceptions(self): # Emscripten SjLj with and without Emscripten EH support self.set_setting('SUPPORT_LONGJMP', 'emscripten') self.set_setting('DEFAULT_TO_CXX') # See comments on @with_all_eh_sjlj - for disable_catching in [0, 1]: + for disable_catching in (0, 1): self.set_setting('DISABLE_EXCEPTION_CATCHING', disable_catching) self.do_core_test('test_longjmp.c') # Wasm SjLj with and without Wasm EH support @@ -888,7 +888,7 @@ def test_longjmp_with_and_without_exceptions(self): if '-fsanitize=address' in self.emcc_args: self.skipTest('Wasm EH does not work with asan yet') self.emcc_args.append('-fwasm-exceptions') - for arg in ['-fwasm-exceptions', '-fno-exceptions']: + for arg in ('-fwasm-exceptions', '-fno-exceptions'): self.do_core_test('test_longjmp.c', emcc_args=[arg]) # Wasm SjLj with and with new EH (exnref) support self.set_setting('WASM_EXNREF') @@ -931,7 +931,7 @@ def test_longjmp_exc(self): self.do_core_test('test_longjmp_exc.c', assert_returncode=NON_ZERO) def test_longjmp_throw(self): - for disable_throw in [0, 1]: + for disable_throw in (0, 1): print(disable_throw) self.set_setting('DISABLE_EXCEPTION_CATCHING', disable_throw) self.do_core_test('test_longjmp_throw.cpp') @@ -962,7 +962,7 @@ def test_setjmp_many(self): return 0; } ''' - for num in [1, 5, 20, 1000]: + for num in (1, 5, 20, 1000): print('NUM=%d' % num) self.do_run(src.replace('NUM', str(num)), '0\n' * num) @@ -1015,7 +1015,7 @@ def test_exceptions_with_and_without_longjmp(self): self.maybe_closure() # Emscripten EH with and without Emscripten SjLj support self.set_setting('DISABLE_EXCEPTION_CATCHING', 0) - for support_longjmp in [0, 'emscripten']: + for support_longjmp in (0, 'emscripten'): self.set_setting('SUPPORT_LONGJMP', support_longjmp) self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught') # Wasm EH with and without Wasm SjLj support @@ -1026,18 +1026,18 @@ def test_exceptions_with_and_without_longjmp(self): if '-fsanitize=address' in self.emcc_args: self.skipTest('Wasm EH does not work with asan yet') self.emcc_args.append('-fwasm-exceptions') - for support_longjmp in [0, 'wasm']: + for support_longjmp in (0, 'wasm'): self.set_setting('SUPPORT_LONGJMP', support_longjmp) self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught') # Wasm new EH (exnref) with and without Wasm SjLj support self.set_setting('WASM_EXNREF') - for support_longjmp in [0, 'wasm']: + for support_longjmp in (0, 'wasm'): self.set_setting('SUPPORT_LONGJMP', support_longjmp) self.do_run_in_out_file_test('core/test_exceptions.cpp', out_suffix='_caught') def test_exceptions_off(self): self.set_setting('DISABLE_EXCEPTION_CATCHING') - for support_longjmp in [0, 1]: + for support_longjmp in (0, 1): self.set_setting('SUPPORT_LONGJMP', support_longjmp) self.do_runf('core/test_exceptions.cpp', assert_returncode=NON_ZERO) @@ -1047,7 +1047,7 @@ def test_exceptions_minimal_runtime(self): self.maybe_closure() self.set_setting('MINIMAL_RUNTIME') self.emcc_args += ['--pre-js', test_file('minimal_runtime_exit_handling.js')] - for support_longjmp in [0, 1]: + for support_longjmp in (0, 1): self.set_setting('SUPPORT_LONGJMP', support_longjmp) self.set_setting('DISABLE_EXCEPTION_CATCHING', 0) @@ -1102,7 +1102,7 @@ class MyException { @with_all_eh_sjlj def test_exceptions_2(self): - for safe in [0, 1]: + for safe in (0, 1): print(safe) if safe and '-fsanitize=address' in self.emcc_args: # Can't use safe heap with ASan @@ -1632,7 +1632,7 @@ def test_float_builtins(self): def test_segfault(self): self.set_setting('SAFE_HEAP') - for addr in ['get_null()', 'new D2()']: + for addr in ('get_null()', 'new D2()'): print(addr) src = r''' #include @@ -5291,7 +5291,7 @@ def test_sscanf(self): def test_sscanf_2(self): # doubles - for ftype in ['float', 'double']: + for ftype in ('float', 'double'): src = r''' #include @@ -5937,7 +5937,7 @@ def test_sigaction_default(self, signal, exit_code, assert_identical): def test_unistd_access(self): self.uses_es6 = True orig_compiler_opts = self.emcc_args.copy() - for fs in ['MEMFS', 'NODEFS']: + for fs in ('MEMFS', 'NODEFS'): self.emcc_args = orig_compiler_opts + ['-D' + fs] if self.get_setting('WASMFS'): if fs == 'NODEFS': @@ -6089,7 +6089,7 @@ def test_unistd_symlink_on_nodefs(self): @also_with_wasm_bigint def test_unistd_io(self): orig_compiler_opts = self.emcc_args.copy() - for fs in ['MEMFS', 'NODEFS']: + for fs in ('MEMFS', 'NODEFS'): self.clear() self.emcc_args = orig_compiler_opts + ['-D' + fs] if fs == 'NODEFS': @@ -6921,7 +6921,7 @@ def test_autodebug_wasm(self): # (but without the specific output, as it is logging the actual locals # used and so forth, which will change between opt modes and updates of # llvm etc.) - for msg in ['log_execution', 'get_i32', 'set_i32', 'load_ptr', 'load_val', 'store_ptr', 'store_val']: + for msg in ('log_execution', 'get_i32', 'set_i32', 'load_ptr', 'load_val', 'store_ptr', 'store_val'): self.assertIn(msg, output) ### Integration tests diff --git a/test/test_interactive.py b/test/test_interactive.py index 9d3c20b3a7a66..5c53b37e23425 100644 --- a/test/test_interactive.py +++ b/test/test_interactive.py @@ -234,7 +234,7 @@ def test_threadprofiler(self): # Test that event backproxying works. def test_html5_callbacks_on_calling_thread(self): # TODO: Make this automatic by injecting mouse event in e.g. shell html file. - for args in [[], ['-DTEST_SYNC_BLOCKING_LOOP=1']]: + for args in ([], ['-DTEST_SYNC_BLOCKING_LOOP=1']): self.btest('html5_callbacks_on_calling_thread.c', expected='1', args=args + ['-sDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR', '-pthread', '-sPROXY_TO_PTHREAD']) # Test that it is possible to register HTML5 event callbacks on either main browser thread, or @@ -261,7 +261,7 @@ def test_emscripten_hide_mouse(self, args): # Tests that WebGL can be run on another thread after first having run it on one thread (and that thread has exited). The intent of this is to stress graceful deinit semantics, so that it is not possible to "taint" a Canvas # to a bad state after a rendering thread in a program quits and restarts. (perhaps e.g. between level loads, or subsystem loads/restarts or something like that) def test_webgl_offscreen_canvas_in_two_pthreads(self): - for args in [['-sOFFSCREENCANVAS_SUPPORT', '-DTEST_OFFSCREENCANVAS=1'], ['-sOFFSCREEN_FRAMEBUFFER']]: + for args in (['-sOFFSCREENCANVAS_SUPPORT', '-DTEST_OFFSCREENCANVAS=1'], ['-sOFFSCREEN_FRAMEBUFFER']): self.btest('gl_in_two_pthreads.cpp', expected='1', args=args + ['-pthread', '-lGL', '-sGL_DEBUG', '-sPROXY_TO_PTHREAD']) # Tests creating a Web Audio context using Emscripten library_webaudio.js feature. diff --git a/test/test_other.py b/test/test_other.py index f6f0728c7ee7f..d22af67a4fa78 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -516,7 +516,7 @@ def test_dumpmachine(self): }) def test_emcc_2(self, compiler, suffix): # emcc src.cpp -c and emcc -c src.cpp -o src.[o|foo|so] ==> should always give an object file - for args in [[], ['-o', 'src.o'], ['-o', 'src.foo'], ['-o', 'src.so']]: + for args in ([], ['-o', 'src.o'], ['-o', 'src.foo'], ['-o', 'src.so']): print('args:', args) target = args[1] if len(args) == 2 else 'hello_world.o' self.clear() @@ -550,7 +550,7 @@ def test_emcc_3(self, compiler, suffix): self.assertContained('hello, world!', self.run_js('a.out.js')) # emcc [..] -o [path] ==> should work with absolute paths - for path in [os.path.abspath(Path('../file1.js')), Path('b_dir/file2.js')]: + for path in (os.path.abspath(Path('../file1.js')), Path('b_dir/file2.js')): print(path) os.chdir(self.get_dir()) self.clear() @@ -859,7 +859,7 @@ def test_emsize(self): # emcc test/hello_world.c -Oz --closure 1 -o test/other/test_emsize.js expected = read_file(test_file('other/test_emsize.out')) cmd = [emsize, test_file('other/test_emsize.js')] - for command in [cmd, cmd + ['--format=sysv']]: + for command in (cmd, cmd + ['--format=sysv']): output = self.run_process(command, stdout=PIPE).stdout self.assertContained(expected, output) @@ -1160,7 +1160,7 @@ def test_use_cxx(self): @with_both_compilers def test_cxx11(self, compiler): - for std in ['-std=c++11', '--std=c++11']: + for std in ('-std=c++11', '--std=c++11'): self.run_process([compiler, std, test_file('hello_cxx11.cpp')]) # Regression test for issue #4522: Incorrect CC vs CXX detection @@ -1172,13 +1172,13 @@ def test_incorrect_c_detection(self, compiler): self.run_process([compiler, '-c', '-lembind', '--embed-file', 'test.c', test_file('hello_world.cpp')]) def test_odd_suffixes(self): - for suffix in ['CPP', 'c++', 'C++', 'cxx', 'CXX', 'cc', 'CC']: + for suffix in ('CPP', 'c++', 'C++', 'cxx', 'CXX', 'cc', 'CC'): self.clear() print(suffix) shutil.copyfile(test_file('hello_world.c'), 'test.' + suffix) self.do_runf('test.' + suffix, 'hello, world!') - for suffix in ['lo']: + for suffix in ('lo'): self.clear() print(suffix) self.run_process([EMCC, test_file('hello_world.c'), '-shared', '-o', 'binary.' + suffix]) @@ -1188,7 +1188,7 @@ def test_odd_suffixes(self): def test_preprocessed_input(self): # .i and .ii files are assumed to be the output the pre-processor so clang doesn't add include # paths. This means we can only compile and run things that don't contain includes. - for suffix in ['.i', '.ii']: + for suffix in ('.i', '.ii'): create_file('simple' + suffix, ''' #ifdef __cplusplus extern "C" { @@ -2779,7 +2779,7 @@ def test_prepost(self): self.assertNotContained('post-run\n', output) # noInitialRun prevents run - for no_initial_run, run_dep in [(0, 0), (1, 0), (0, 1)]: + for no_initial_run, run_dep in ((0, 0), (1, 0), (0, 1)): print(no_initial_run, run_dep) args = ['-sWASM_ASYNC_COMPILATION=0', '-sEXPORTED_RUNTIME_METHODS=callMain'] if no_initial_run: @@ -2928,15 +2928,15 @@ def test_js_optimizer_py(self, name, passes): def test_m_mm(self): create_file('foo.c', '#include ') - for opt in ['M', 'MM']: + for opt in ('M', 'MM'): proc = self.run_process([EMCC, 'foo.c', '-' + opt], stdout=PIPE, stderr=PIPE) self.assertContained('foo.o: ', proc.stdout) self.assertNotContained('error', proc.stderr) @uses_canonical_tmp def test_emcc_debug_files(self): - for opts in [0, 1, 2, 3]: - for debug in [None, '1', '2']: + for opts in (0, 1, 2, 3): + for debug in (None, '1', '2'): print(opts, debug) if os.path.exists(self.canonical_temp_dir): shutil.rmtree(self.canonical_temp_dir) @@ -4932,7 +4932,7 @@ def test_no_exit_runtime(self, opts): } ''') - for no_exit in [1, 0]: + for no_exit in (1, 0): print(no_exit) cmd = [EMXX] + opts + ['code.cpp', '-sEXIT_RUNTIME=' + str(1 - no_exit)] + self.get_emcc_args() if self.is_wasm(): @@ -5012,15 +5012,15 @@ def test(cxx, no_exit, assertions, flush=0, keepalive=0, filesystem=1): test(cxx=0, no_exit=1, assertions=1, keepalive=1) test(cxx=0, no_exit=1, assertions=1, filesystem=0) - for cxx in [0, 1]: - for no_exit in [0, 1]: - for assertions in [0, 1]: - for flush in [0, 1]: + for cxx in (0, 1): + for no_exit in (0, 1): + for assertions in (0, 1): + for flush in (0, 1): test(cxx, no_exit, assertions, flush) def test_extra_opt_levels(self): # Opt levels that we don't tend to test elsewhere - for opt in ['-Og', '-Ofast']: + for opt in ('-Og', '-Ofast'): print(opt) proc = self.run_process([EMCC, '-v', test_file('hello_world.c'), opt], stderr=PIPE) self.assertContained(opt, proc.stderr) @@ -5173,7 +5173,7 @@ def test_valid_abspath_2(self): def test_warn_dylibs(self): shared_suffixes = ['.so', '.dylib', '.dll'] - for suffix in ['.o', '.bc', '.so', '.dylib', '.js', '.html']: + for suffix in ('.o', '.bc', '.so', '.dylib', '.js', '.html'): print(suffix) cmd = [EMCC, test_file('hello_world.c'), '-o', 'out' + suffix] if suffix in ['.o', '.bc']: @@ -5341,9 +5341,9 @@ def test_bad_function_pointer_cast(self, wasm, safe): } ''') - for opts in [0, 1, 2]: - for emulate_casts in [0, 1]: - for relocatable in [0, 1]: + for opts in (0, 1, 2): + for emulate_casts in (0, 1): + for relocatable in (0, 1): # wasm2js is not compatible with relocatable mode if not wasm and relocatable: continue @@ -5369,7 +5369,7 @@ def test_bad_function_pointer_cast(self, wasm, safe): self.assertContained('function signature mismatch', output) def test_bad_export(self): - for m in ['', ' ']: + for m in ('', ' '): self.clear() cmd = [EMCC, test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=["' + m + '_main"]'] print(cmd) @@ -5477,9 +5477,9 @@ def test_returncode(self, no_exit): #endif } ''') - for code in [0, 123]: - for call_exit in [0, 1]: - for async_compile in [0, 1]: + for code in (0, 123): + for call_exit in (0, 1): + for async_compile in (0, 1): self.run_process([EMCC, 'src.c', '-sENVIRONMENT=node,shell', '-DCODE=%d' % code, '-sEXIT_RUNTIME=%d' % (1 - no_exit), '-DCALL_EXIT=%d' % call_exit, '-sWASM_ASYNC_COMPILATION=%d' % async_compile]) for engine in config.JS_ENGINES: # async compilation can't return a code in d8 @@ -5504,8 +5504,8 @@ def test_emscripten_force_exit_NO_EXIT_RUNTIME(self): #endif } ''') - for no_exit in [0, 1]: - for call_exit in [0, 1]: + for no_exit in (0, 1): + for call_exit in (0, 1): self.run_process([EMCC, 'src.c', '-sEXIT_RUNTIME=%d' % (1 - no_exit), '-DCALL_EXIT=%d' % call_exit]) print(no_exit, call_exit) out = self.run_js('a.out.js') @@ -6572,7 +6572,7 @@ def test_link_with_a_static(self): self.run_process([EMAR, 'rc', 'libtest.a', 'x.o']) self.run_process([EMRANLIB, 'libtest.a']) - for args in [[], ['-O2']]: + for args in ([], ['-O2']): print('args:', args) self.run_process([EMCC, 'z.o', 'libtest.a'] + args) self.run_js('a.out.js', assert_returncode=161) @@ -6879,7 +6879,7 @@ def test_failing_alloc(self, growth): ('', '', []), ('EM_ASM( Module.temp = _sbrk() );', 'EM_ASM( assert(Module.temp === _sbrk(), "must not adjust brk when an alloc fails!") );', []), ]: - for aborting_args in [[], ['-sABORTING_MALLOC=0']]: + for aborting_args in ([], ['-sABORTING_MALLOC=0']): create_file('main.cpp', r''' #include #include @@ -8349,9 +8349,9 @@ def test_disable_inlining(self): @crossplatform def test_output_eol(self): - for params in [[], ['--proxy-to-worker'], ['--proxy-to-worker', '-sWASM=0']]: - for output_suffix in ['html', 'js']: - for eol in ['windows', 'linux']: + for params in ([], ['--proxy-to-worker'], ['--proxy-to-worker', '-sWASM=0']): + for output_suffix in ('html', 'js'): + for eol in ('windows', 'linux'): files = ['a.js'] if output_suffix == 'html': files += ['a.html'] @@ -8483,7 +8483,7 @@ def test_binaryen_ctors(self): ''') self.run_process([EMXX, 'src.cpp']) correct = self.run_js('a.out.js') - for args in [[], ['-sRELOCATABLE']]: + for args in ([], ['-sRELOCATABLE']): print(args) self.run_process([EMXX, 'src.cpp', '-o', 'b.out.js'] + args) seen = self.run_js('b.out.js') @@ -8838,7 +8838,7 @@ def test_legalize_js_ffi(self): @disabled('https://github.com/WebAssembly/binaryen/pull/6428') def test_no_legalize_js_ffi(self): - for legalizing in [0, 1]: + for legalizing in (0, 1): # test minimal JS FFI legalization for invoke and dyncalls args = ['-sMAIN_MODULE=2', '-O3', '-sDISABLE_EXCEPTION_CATCHING=0', '-g'] if not legalizing: @@ -9256,7 +9256,7 @@ def test_clear_error_on_massive_static_data(self): self.assertContained('wasm-ld: error: initial memory too small', err) def test_o_level_clamp(self): - for level in [3, 4, 20]: + for level in (3, 4, 20): err = self.run_process([EMCC, '-O' + str(level), test_file('hello_world.c')], stderr=PIPE).stderr self.assertContainedIf("optimization level '-O" + str(level) + "' is not supported; using '-O3' instead", err, level > 3) @@ -9327,7 +9327,7 @@ def test_standalone_system_headers(self): else: create_file('a.c', inc) create_file('b.c', inc) - for std in [[], ['-std=c89']]: + for std in ([], ['-std=c89']): self.run_process([EMCC] + std + ['-Werror', '-Wall', '-pedantic', 'a.c', 'b.c']) @is_slow_test @@ -10848,7 +10848,7 @@ def check_size(f, expected_size): self.assertLess(obtained_size, expected_size) self.run_process([PYTHON, test_file('gen_many_js_functions.py'), 'library_long.js', 'main_long.c']) - for wasm in [[], ['-sWASM=0']]: + for wasm in ([], ['-sWASM=0']): # Currently we rely on Closure for full minification of every appearance of JS function names. # TODO: Add minification also for non-Closure users and add [] to this list to test minification without Closure. for closure in [['--closure=1']]: @@ -10865,7 +10865,7 @@ def check_size(f, expected_size): # Checks that C++ exceptions managing invoke_*() wrappers will not be generated if exceptions are disabled def test_no_invoke_functions_are_generated_if_exception_catching_is_disabled(self): self.skipTest('Skipping other.test_no_invoke_functions_are_generated_if_exception_catching_is_disabled: Enable after new version of fastcomp has been tagged') - for args in [[], ['-sWASM=0']]: + for args in ([], ['-sWASM=0']): self.run_process([EMXX, test_file('hello_world.cpp'), '-sDISABLE_EXCEPTION_CATCHING', '-o', 'a.html'] + args) output = read_file('a.js') self.assertContained('_main', output) # Smoke test that we actually compiled @@ -10874,7 +10874,7 @@ def test_no_invoke_functions_are_generated_if_exception_catching_is_disabled(sel # Verifies that only the minimal needed set of invoke_*() functions will be generated when C++ exceptions are enabled def test_no_excessive_invoke_functions_are_generated_when_exceptions_are_enabled(self): self.skipTest('Skipping other.test_no_excessive_invoke_functions_are_generated_when_exceptions_are_enabled: Enable after new version of fastcomp has been tagged') - for args in [[], ['-sWASM=0']]: + for args in ([], ['-sWASM=0']): self.run_process([EMXX, test_file('invoke_i.cpp'), '-sDISABLE_EXCEPTION_CATCHING=0', '-o', 'a.html'] + args) output = read_file('a.js') self.assertContained('invoke_i', output) @@ -11552,7 +11552,7 @@ def test_llvm_includes(self): def test_mmap_and_munmap(self): emcc_args = [] - for f in ['data_ro.dat', 'data_rw.dat']: + for f in ('data_ro.dat', 'data_rw.dat'): create_file(f, 'Test file') emcc_args.extend(['--embed-file', f]) self.do_other_test('test_mmap_and_munmap.c', emcc_args) @@ -12647,7 +12647,7 @@ def test_jslib_exported_functions(self): self.assertContained("Module['Foo'] = ", read_file('a.out.js')) def test_wasm2js_no_dylink(self): - for arg in ['-sMAIN_MODULE', '-sSIDE_MODULE', '-sRELOCATABLE']: + for arg in ('-sMAIN_MODULE', '-sSIDE_MODULE', '-sRELOCATABLE'): print(arg) err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sWASM=0', arg]) self.assertContained('WASM2JS is not compatible with relocatable output', err) @@ -13820,7 +13820,7 @@ def test_legacy_runtime(self): # In strict mode the library function is not even available, so we get a build time error self.set_setting('STRICT') self.clear_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE') - for opt in ['-O0', '-O3']: + for opt in ('-O0', '-O3'): err = self.expect_fail([EMCC, test_file('other/test_legacy_runtime.c'), opt] + self.get_emcc_args()) self.assertContained('warning: invalid item in EXPORTED_RUNTIME_METHODS: allocate', err) @@ -14082,10 +14082,10 @@ def test_bigint64array_polyfill(self): ) output = json.loads(self.run_js('test.js')) self.assertEqual(output['BigInt64Array_name'], 'createBigInt64Array') - for key in ['arr1_to_arr1', 'arr1_to_arr2', 'arr2_to_arr1']: + for key in ('arr1_to_arr1', 'arr1_to_arr2', 'arr2_to_arr1'): print(key + '_unsigned') self.assertEqual(output[key + '_unsigned'], bigint_list_unsigned_n) - for key in ['arr1_to_arr1', 'arr1_to_arr2', 'arr2_to_arr1']: + for key in ('arr1_to_arr1', 'arr1_to_arr2', 'arr2_to_arr1'): print(key + '_signed') self.assertEqual(output[key + '_signed'], bigint_list_signed_n) diff --git a/test/test_sanity.py b/test/test_sanity.py index 89a0f60b77a27..62257eedbe6da 100644 --- a/test/test_sanity.py +++ b/test/test_sanity.py @@ -203,7 +203,7 @@ def make_new_executable(name): self.assertNotContained('}}}', config_data) self.assertContained('{{{', template_data) self.assertContained('}}}', template_data) - for content in ['LLVM_ROOT', 'NODE_JS', 'JS_ENGINES']: + for content in ('LLVM_ROOT', 'NODE_JS', 'JS_ENGINES'): self.assertContained(content, config_data) # The guessed config should be ok @@ -214,7 +214,7 @@ def make_new_executable(name): for command in commands: # Second run, with bad EM_CONFIG - for settings in ['blah', 'LLVM_ROOT="blarg"; JS_ENGINES=[]; NODE_JS=[]; SPIDERMONKEY_ENGINE=[]']: + for settings in ('blah', 'LLVM_ROOT="blarg"; JS_ENGINES=[]; NODE_JS=[]; SPIDERMONKEY_ENGINE=[]'): try: utils.write_file(default_config, settings) output = self.do(command) @@ -282,12 +282,12 @@ def test_node(self): ensure_dir('fake') - for version, succeed in [('v0.8.0', False), + for version, succeed in (('v0.8.0', False), ('v4.1.0', False), ('v10.18.0', False), ('v16.20.0', True), ('v16.20.1-pre', True), - ('cheez', False)]: + ('cheez', False)): print(version, succeed) delete_file(SANITY_FILE) utils.write_file(self.in_dir('fake', 'nodejs'), '''#!/bin/sh @@ -541,7 +541,7 @@ def test_emcc_ports(self): PORTS_DIR = ports.Ports.get_dir() - for i in [0, 1]: + for i in (0, 1): self.do([EMCC, '--clear-cache']) print(i) if i == 0: diff --git a/tools/emscripten.py b/tools/emscripten.py index 13eebc2155000..8319bd9ac46dd 100644 --- a/tools/emscripten.py +++ b/tools/emscripten.py @@ -82,7 +82,7 @@ def maybe_disable_filesystem(imports): not including the filesystem would mean not including the full JS libraries, and the same for MAIN_MODULE=1 since a side module might need the filesystem. """ - if any(settings[s] for s in ['FORCE_FILESYSTEM', 'INCLUDE_FULL_LIBRARY']): + if any(settings[s] for s in ('FORCE_FILESYSTEM', 'INCLUDE_FULL_LIBRARY')): return if settings.MAIN_MODULE == 1: return @@ -95,7 +95,7 @@ def maybe_disable_filesystem(imports): syscall_prefixes = ('__syscall_', 'fd_') side_module_imports = [shared.demangle_c_symbol_name(s) for s in settings.SIDE_MODULE_IMPORTS] all_imports = set(imports).union(side_module_imports) - syscalls = {d for d in all_imports if d.startswith(syscall_prefixes) or d in ['path_open']} + syscalls = {d for d in all_imports if d.startswith(syscall_prefixes) or d == 'path_open'} # check if the only filesystem syscalls are in: close, ioctl, llseek, write # (without open, etc.. nothing substantial can be done, so we can disable # extra filesystem support in that case) diff --git a/tools/file_packager.py b/tools/file_packager.py index d49b919141012..6612a902ecbea 100755 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -577,7 +577,7 @@ def was_seen(name): if options.depfile: with open(options.depfile, 'w') as f: - for target in [data_target, options.jsoutput]: + for target in (data_target, options.jsoutput): if target: f.write(escape_for_makefile(target)) f.write(' \\\n') diff --git a/tools/shared.py b/tools/shared.py index 60fa92e01c4cb..a249d975bdbca 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -448,7 +448,7 @@ def perform_sanity_checks(): check_node() with ToolchainProfiler.profile_block('sanity LLVM'): - for cmd in [CLANG_CC, LLVM_AR]: + for cmd in (CLANG_CC, LLVM_AR): if not os.path.exists(cmd) and not os.path.exists(cmd + '.exe'): # .exe extension required for Windows exit_with_error('cannot find %s, check the paths in %s', cmd, config.EM_CONFIG)