Skip to content

Commit

Permalink
Prefer tuples over lists for python constants. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Sep 5, 2024
1 parent 73411b3 commit ffdbe85
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 89 deletions.
2 changes: 1 addition & 1 deletion test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <assert.h>
Expand Down
34 changes: 17 additions & 17 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"'],
Expand Down Expand Up @@ -1552,7 +1552,7 @@ def test_worker(self):
</html>
''' % 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']
Expand Down Expand Up @@ -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'])

Expand All @@ -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'])

Expand Down Expand Up @@ -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')

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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 <stdio.h>
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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', '<script src="test.js"></script>')
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 <stdio.h>
Expand Down Expand Up @@ -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 <stdio.h>
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/test_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
Loading

0 comments on commit ffdbe85

Please sign in to comment.