Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion emar.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

from tools import shared

shared.exec_process([shared.LLVM_AR] + sys.argv[1:])
shared.exec_process([shared.LLVM_AR, *sys.argv[1:]])
3 changes: 2 additions & 1 deletion embuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@

# Additional tasks on top of MINIMAL_TASKS that are necessary for PIC testing on
# CI (which has slightly more tests than other modes that want to use MINIMAL)
MINIMAL_PIC_TASKS = MINIMAL_TASKS + [
MINIMAL_PIC_TASKS = [
*MINIMAL_TASKS,
'libc-mt',
'libc_optz-mt',
'libc_optz-mt-debug',
Expand Down
8 changes: 4 additions & 4 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def main(args):
if len(args) == 2 and args[1] == '-v':
# autoconf likes to see 'GNU' in the output to enable shared object support
print(cmdline.version_string(), file=sys.stderr)
return shared.check_call([clang, '-v'] + compile.get_target_flags(), check=False).returncode
return shared.check_call([clang, '-v', *compile.get_target_flags()], check=False).returncode

# Additional compiler flags that we treat as if they were passed to us on the
# commandline
Expand Down Expand Up @@ -295,7 +295,7 @@ def main(args):
phase_setup(state)

if '-print-resource-dir' in args or any(a.startswith('--print-prog-name') for a in args):
shared.exec_process([clang] + compile.get_cflags(tuple(args)) + args)
shared.exec_process([clang, *compile.get_cflags(tuple(args)), *args])
assert False, 'exec_process should not return'

if '--cflags' in args:
Expand All @@ -314,7 +314,7 @@ def main(args):
linker_args = separate_linker_flags(newargs)[1]
linker_args = [f.value for f in linker_args]
# Delay import of link.py to avoid processing this file when only compiling
from tools import link # noqa: PLC0415
from tools import link
link.run_post_link(options.input_files[0], options, linker_args)
return 0

Expand Down Expand Up @@ -542,7 +542,7 @@ def compile_source_file(input_file):
cmd = get_clang_command()
if ext == '.pcm':
cmd = [c for c in cmd if not c.startswith('-fprebuilt-module-path=')]
cmd += compile_args + ['-c', input_file, '-o', output_file]
cmd += [*compile_args, '-c', input_file, '-o', output_file]
if options.requested_debug == '-gsplit-dwarf':
# When running in COMPILE_AND_LINK mode we compile objects to a temporary location
# but we want the `.dwo` file to be generated in the current working directory,
Expand Down
2 changes: 1 addition & 1 deletion emranlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

from tools import shared

shared.exec_process([shared.LLVM_RANLIB] + sys.argv[1:])
shared.exec_process([shared.LLVM_RANLIB, *sys.argv[1:]])
2 changes: 1 addition & 1 deletion emscan-deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
# Add any clang flags that emcc would add.
newargs += compile.get_cflags(tuple(argv))

shared.exec_process([shared.CLANG_SCAN_DEPS] + newargs)
shared.exec_process([shared.CLANG_SCAN_DEPS, *newargs])
2 changes: 1 addition & 1 deletion emstrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def run():
continue
new_args.append(arg)

shared.exec_process([llvm_strip] + new_args)
shared.exec_process([llvm_strip, *new_args])


if __name__ == '__main__':
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[project]
name = "emscripten"
requires-python = ">=3.10"

[tool.ruff]
Expand Down Expand Up @@ -34,6 +35,7 @@ lint.select = [
"PL",
"UP",
"W",
"RUF",
"YTT",
]
lint.external = [ "D" ]
Expand Down Expand Up @@ -76,6 +78,11 @@ lint.ignore = [
"PLW0603",
"PLW1510",
"PLW2901",
"RUF012", # https://docs.astral.sh/ruff/rules/mutable-class-default/
"RUF015", # https://docs.astral.sh/ruff/rules/unnecessary-iterable-allocation-for-first-element/
"RUF027", # https://docs.astral.sh/ruff/rules/missing-f-string-syntax/
"RUF039", # https://docs.astral.sh/ruff/rules/unraw-re-pattern/
"RUF067", # https://docs.astral.sh/ruff/rules/non-empty-init-module/
"UP030", # TODO
"UP031", # TODO
"UP032", # TODO
Expand All @@ -84,6 +91,7 @@ lint.per-file-ignores."tools/ports/*.py" = [ "ARG001", "ARG005" ]
lint.per-file-ignores."test/other/ports/*.py" = [ "ARG001" ]
lint.per-file-ignores."test/parallel_testsuite.py" = [ "ARG002" ]
lint.per-file-ignores."test/test_benchmark.py" = [ "ARG002" ]
lint.per-file-ignores."test/*.py" = [ "RUF005" ]
lint.mccabe.max-complexity = 51 # Recommended: 10
lint.pylint.allow-magic-value-types = [
"bytes",
Expand Down
2 changes: 1 addition & 1 deletion site/source/get_api_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def exportItems():
def main():
parser = optparse.OptionParser(usage="Usage: %prog [options] version")
parser.add_option("-s", "--siteapi", dest="siteapi", default="http://www.developer.nokia.com/Community/Wiki/api.php", help="Location of API")
(options, args) = parser.parse_args()
_options, _args = parser.parse_args()
# print 'Site: %s' % options.siteapi
parseFiles()
exportItems()
Expand Down
2 changes: 1 addition & 1 deletion site/source/get_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def fixcodemarkuplinks(matchobj):
def main():
parser = optparse.OptionParser(version="%prog 0.1.1", usage="Usage: %prog [options] version")
parser.add_option("-c", "--clonewiki", action="store_true", default=False, dest="clonewiki", help="Clean and clone the latest wiki")
options, args = parser.parse_args()
options = parser.parse_args()[0]

print('Clone wiki: %s' % options.clonewiki)
if options.clonewiki:
Expand Down
2 changes: 1 addition & 1 deletion test/benchmark/benchmark_sse.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def run_benchmark(benchmark_file, results_file, build_args):
print('wasm_results', wasm_results)

def strip_comments(text):
return re.sub(r'//.*?\n|/\*.*?\*/', '', text, flags=re.S) # noqa
return re.sub(r'//.*?\n|/\*.*?\*/', '', text, flags=re.S)

benchmark_results = strip_comments(wasm_results)
print('stripped', benchmark_results)
Expand Down
4 changes: 2 additions & 2 deletions test/browser_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ def browser_open(cls, url):
if hasattr(config, 'launch_prefix'):
browser_args = list(config.launch_prefix) + browser_args

logger.info('Launching browser: %s', str(browser_args))
logger.info(f'Launching browser: {browser_args}')

if (WINDOWS and is_firefox()) or is_safari():
cls.launch_browser_harness_with_proc_snapshot_workaround(parallel_harness, config, browser_args, url)
Expand Down Expand Up @@ -872,7 +872,7 @@ def run_browser(self, html_file, expected=None, message=None, timeout=None, extr
output = self.harness_out_queue.get(block=True, timeout=timeout)
except queue.Empty:
BrowserCore.unresponsive_tests += 1
print(f'[unresponsive test: {self.id()} total unresponsive={str(BrowserCore.unresponsive_tests)}]')
print(f'[unresponsive test: {self.id()} total unresponsive={BrowserCore.unresponsive_tests}]')
self.browser_restart()
# Rather than fail the test here, let fail on the `assertContained` so
# that the test can be retried via `extra_tries`
Expand Down
2 changes: 1 addition & 1 deletion test/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def run_tests(options, suite):
if utils.get_env_bool('CI'):
# output fd must remain open until after testRunner.run() below
output = open('out/test-results.xml', 'wb')
import xmlrunner # type: ignore # noqa: PLC0415
import xmlrunner # type: ignore
testRunner = xmlrunner.XMLTestRunner(output=output, verbosity=2,
failfast=options.failfast)
print('Writing XML test output to ' + os.path.abspath(output.name))
Expand Down
2 changes: 1 addition & 1 deletion test/sockets/socket_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def run(self):
s.bind(('127.0.0.1', port))
s.listen(1)
print('listener', port, 'waiting for connection')
conn, addr = s.accept()
conn, _addr = s.accept()
self.conn = conn
while True:
time.sleep(0.5)
Expand Down
3 changes: 2 additions & 1 deletion test/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ def setUpClass(cls):
pass
try:
with common.chdir(os.path.expanduser('~/Dev/mozilla-central')):
fingerprint.append('sm: ' + [line for line in run_process(['hg', 'tip'], stdout=PIPE).stdout.splitlines() if 'changeset' in line][0])
hg_tip = run_process(['hg', 'tip'], stdout=PIPE).stdout
fingerprint.append('sm: ' + next(line for line in hg_tip.splitlines() if 'changeset' in line))
except Exception:
pass
fingerprint.append('llvm: ' + config.LLVM_ROOT)
Expand Down
16 changes: 8 additions & 8 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1750,9 +1750,9 @@ def book_path(path):
for image in images:
cflags += ['--preload-file', f'{book_path(image)}@{os.path.basename(image)}']

lib = [l for l in libs if program in os.path.basename(l)][0]
libs = [l for l in libs if program in os.path.basename(l)]

self.reftest(lib, book_path(program.replace('.o', '.png')), cflags=cflags)
self.reftest(libs[0], book_path(program.replace('.o', '.png')), cflags=cflags)

@requires_graphics_hardware
@parameterized({
Expand Down Expand Up @@ -3292,12 +3292,12 @@ def test_async_iostream(self):
# ASYNCIFY_IMPORTS.
# To make the test more precise we also use ASYNCIFY_IGNORE_INDIRECT here.
@parameterized({
'': (['-sASYNCIFY_IMPORTS=sync_tunnel,sync_tunnel_bool'],), # noqa
'pattern_imports': (['-sASYNCIFY_IMPORTS=[sync_tun*]'],), # noqa
'response': (['-sASYNCIFY_IMPORTS=@filey.txt'],), # noqa
'nothing': (['-DBAD'],), # noqa
'empty_list': (['-DBAD', '-sASYNCIFY_IMPORTS=[]'],), # noqa
'em_js_bad': (['-DBAD', '-DUSE_EM_JS'],), # noqa
'': (['-sASYNCIFY_IMPORTS=sync_tunnel,sync_tunnel_bool'],),
'pattern_imports': (['-sASYNCIFY_IMPORTS=[sync_tun*]'],),
'response': (['-sASYNCIFY_IMPORTS=@filey.txt'],),
'nothing': (['-DBAD'],),
'empty_list': (['-DBAD', '-sASYNCIFY_IMPORTS=[]'],),
'em_js_bad': (['-DBAD', '-DUSE_EM_JS'],),
})
def test_async_returnvalue(self, args):
if '@' in str(args):
Expand Down
2 changes: 1 addition & 1 deletion test/test_closure_args_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def get(ports, settings, shared): # noqa: ARG001
return []


def clear(ports, settings, shared): # noqa: ARG001
def clear(ports, settings, shared):
pass


Expand Down
18 changes: 9 additions & 9 deletions test/test_codesize.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ def strip_numeric_suffixes(funcname):
'O1': (['-O1'],),
'O2': (['-O2'],),
# in -O3, -Os and -Oz we metadce, and they shrink it down to the minimal output we want
'O3': (['-O3'],), # noqa
'Os': (['-Os'],), # noqa
'Oz': (['-Oz'],), # noqa
'O3': (['-O3'],),
'Os': (['-Os'],),
'Oz': (['-Oz'],),
'Os_mr': (['-Os', '-sMINIMAL_RUNTIME'],),
# EVAL_CTORS also removes the __wasm_call_ctors function
'Oz-ctors': (['-Oz', '-sEVAL_CTORS'],),
Expand All @@ -328,11 +328,11 @@ def test_codesize_minimal_pthreads(self, args):
self.run_codesize_test('minimal_main.c', ['-Oz', '-pthread', '-sPROXY_TO_PTHREAD', '-sSTRICT'] + args)

@parameterized({
'noexcept': (['-O2'],), # noqa
'noexcept': (['-O2'],),
# exceptions increases code size significantly
'except': (['-O2', '-fexceptions'],), # noqa
'except': (['-O2', '-fexceptions'],),
# exceptions does not pull in demangling by default, which increases code size
'mangle': (['-O2', '-fexceptions', '-sEXPORTED_FUNCTIONS=_main,_free,___cxa_demangle', '-Wno-deprecated'],), # noqa
'mangle': (['-O2', '-fexceptions', '-sEXPORTED_FUNCTIONS=_main,_free,___cxa_demangle', '-Wno-deprecated'],),
# Wasm EH's code size increase is smaller than that of Emscripten EH
'except_wasm': (['-O2', '-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS=0'],),
'except_wasm_legacy': (['-O2', '-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS'],),
Expand Down Expand Up @@ -386,7 +386,7 @@ def test_codesize_hello(self, args, kwargs={}): # noqa
'O3_grow_standalone': ('mem.c', ['-O3', '-sALLOW_MEMORY_GROWTH', '-sSTANDALONE_WASM']),
# without argc/argv, no support code for them is emitted, even with lto
'O3_standalone_narg_flto':
('mem_no_argv.c', ['-O3', '-sSTANDALONE_WASM', '-flto']), # noqa
('mem_no_argv.c', ['-O3', '-sSTANDALONE_WASM', '-flto']),
})
def test_codesize_mem(self, filename, args):
self.run_codesize_test(filename, args)
Expand All @@ -400,8 +400,8 @@ def test_codesize_libcxxabi_message(self, args):
self.run_codesize_test('libcxxabi_message.cpp', args)

@parameterized({
'js_fs': (['-O3', '-sNO_WASMFS'],), # noqa
'wasmfs': (['-O3', '-sWASMFS'],), # noqa
'js_fs': (['-O3', '-sNO_WASMFS'],),
'wasmfs': (['-O3', '-sWASMFS'],),
})
def test_codesize_files(self, args):
self.run_codesize_test('files.cpp', args)
Expand Down
4 changes: 2 additions & 2 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8028,7 +8028,7 @@ def test_dwarf(self):
self.assertIn((8, 3), src_to_addr)

def get_dwarf_addr(line, col):
addrs = src_to_addr[(line, col)]
addrs = src_to_addr[line, col]
Comment thread
sbc100 marked this conversation as resolved.
# we assume the simple calls have one address
self.assertEqual(len(addrs), 1)
return int(addrs[0], 0)
Expand Down Expand Up @@ -10008,4 +10008,4 @@ def setUp(self):
jsmathz = make_run('jsmathz', cflags=['-Oz'], settings={'JS_MATH': 1})

# TestCoreBase is just a shape for the specific subclasses, we don't test it itself
del TestCoreBase # noqa
del TestCoreBase
27 changes: 13 additions & 14 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# University of Illinois/NCSA Open Source License. Both these licenses can be
# found in the LICENSE file.

# noqa: E241

import glob
import importlib
Expand Down Expand Up @@ -338,7 +337,7 @@ def run_on_pty(self, cmd):
with env_modify({'TERM': 'xterm-color'}):
proc = subprocess.Popen(cmd, stdout=slave, stderr=slave)
while proc.poll() is None:
r, w, x = select.select([master], [], [], 1)
r, _w, _x = select.select([master], [], [], 1)
if r:
output.append(os.read(master, 1024))
return (proc.returncode, b''.join(output))
Expand Down Expand Up @@ -9513,10 +9512,10 @@ def test_pthreads_growth_and_unsigned(self):
read_file('a.out.js'))

@parameterized({
'': ([],), # noqa
'O3': (['-O3'],), # noqa
'closure': (['--closure=1'],), # noqa
'closure_O3': (['--closure=1', '-O3'],), # noqa
'': ([],),
'O3': (['-O3'],),
'closure': (['--closure=1'],),
'closure_O3': (['--closure=1', '-O3'],),
})
def test_EM_ASM_ES6(self, args):
create_file('src.c', r'''
Expand Down Expand Up @@ -10769,14 +10768,14 @@ def test_no_excessive_invoke_functions_are_generated_when_exceptions_are_enabled
self.assertNotContained('invoke_v', output)

@parameterized({
'O0': (False, ['-O0']), # noqa
'O0_emit': (True, ['-O0', '-sEMIT_EMSCRIPTEN_LICENSE']), # noqa
'O2': (False, ['-O2']), # noqa
'O2_emit': (True, ['-O2', '-sEMIT_EMSCRIPTEN_LICENSE']), # noqa
'O2_js_emit': (True, ['-O2', '-sEMIT_EMSCRIPTEN_LICENSE', '-sWASM=0']), # noqa
'O2_closure': (False, ['-O2', '--closure=1']), # noqa
'O2_closure_emit': (True, ['-O2', '-sEMIT_EMSCRIPTEN_LICENSE', '--closure=1']), # noqa
'O2_closure_js_emit': (True, ['-O2', '-sEMIT_EMSCRIPTEN_LICENSE', '--closure=1', '-sWASM=0']), # noqa
'O0': (False, ['-O0']),
'O0_emit': (True, ['-O0', '-sEMIT_EMSCRIPTEN_LICENSE']),
'O2': (False, ['-O2']),
'O2_emit': (True, ['-O2', '-sEMIT_EMSCRIPTEN_LICENSE']),
'O2_js_emit': (True, ['-O2', '-sEMIT_EMSCRIPTEN_LICENSE', '-sWASM=0']),
'O2_closure': (False, ['-O2', '--closure=1']),
'O2_closure_emit': (True, ['-O2', '-sEMIT_EMSCRIPTEN_LICENSE', '--closure=1']),
'O2_closure_js_emit': (True, ['-O2', '-sEMIT_EMSCRIPTEN_LICENSE', '--closure=1', '-sWASM=0']),
})
def test_emscripten_license(self, expect_license, args):
# fastcomp does not support the new license flag
Expand Down
8 changes: 4 additions & 4 deletions test/test_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,10 @@ def test_emconfig(self):
utils.write_file(EM_CONFIG, 'asdfasdfasdfasdf\n')

# Test both relative and absolute paths to the config
self.run_process([EMCC, '--em-config', os.path.abspath('custom_config')] + MINIMAL_HELLO_WORLD)
self.run_process([EMCC, '--em-config', os.path.abspath('custom_config'), *MINIMAL_HELLO_WORLD])
self.assertContained('Hello, world!', self.run_js('a.out.js'))

self.run_process([EMCC, '--em-config', 'custom_config'] + MINIMAL_HELLO_WORLD)
self.run_process([EMCC, '--em-config', 'custom_config', *MINIMAL_HELLO_WORLD])
self.assertContained('Hello, world!', self.run_js('a.out.js'))

def test_emcc_ports(self):
Expand Down Expand Up @@ -634,7 +634,7 @@ def test_wacky_env(self):
restore_and_set_up()

def build():
return self.check_working([EMCC] + MINIMAL_HELLO_WORLD, '')
return self.check_working([EMCC, *MINIMAL_HELLO_WORLD], '')

def test():
self.assertContained('Hello, world!', self.run_js('a.out.js'))
Expand Down Expand Up @@ -670,7 +670,7 @@ def make_fake(report):
def test_with_fake(report, expected):
make_fake(report)
with env_modify({'EMCC_DEBUG': '1'}):
self.check_working([EMCC] + MINIMAL_HELLO_WORLD + ['-c'], expected)
self.check_working([EMCC, *MINIMAL_HELLO_WORLD, '-c'], expected)

test_with_fake('got js backend! JavaScript (asm.js, emscripten) backend', 'LLVM has not been built with the WebAssembly backend')
delete_dir(shared.CANONICAL_TEMP_DIR)
Expand Down
Loading
Loading