Skip to content

Commit

Permalink
Use @wraps on all test decorators
Browse files Browse the repository at this point in the history
Without this the decorated function doesn't mirror properties of the
underlying tests, which was breaking things like `@crossplatform`.

See emscripten-core#18163
  • Loading branch information
sbc100 committed Aug 14, 2024
1 parent c93788f commit 7e86721
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ def decorated(self, *args, **kwargs):
def requires_node(func):
assert callable(func)

@wraps(func)
def decorated(self, *args, **kwargs):
self.require_node()
return func(self, *args, **kwargs)
Expand All @@ -257,6 +258,7 @@ def decorated(self, *args, **kwargs):
def requires_node_canary(func):
assert callable(func)

@wraps(func)
def decorated(self, *args, **kwargs):
self.require_node_canary()
return func(self, *args, **kwargs)
Expand All @@ -267,6 +269,7 @@ def decorated(self, *args, **kwargs):
def requires_wasm64(func):
assert callable(func)

@wraps(func)
def decorated(self, *args, **kwargs):
self.require_wasm64()
return func(self, *args, **kwargs)
Expand All @@ -277,6 +280,7 @@ def decorated(self, *args, **kwargs):
def requires_wasm_eh(func):
assert callable(func)

@wraps(func)
def decorated(self, *args, **kwargs):
self.require_wasm_eh()
return func(self, *args, **kwargs)
Expand All @@ -287,6 +291,7 @@ def decorated(self, *args, **kwargs):
def requires_wasm_exnref(func):
assert callable(func)

@wraps(func)
def decorated(self, *args, **kwargs):
self.require_wasm_exnref()
return func(self, *args, **kwargs)
Expand All @@ -297,6 +302,7 @@ def decorated(self, *args, **kwargs):
def requires_v8(func):
assert callable(func)

@wraps(func)
def decorated(self, *args, **kwargs):
self.require_v8()
return func(self, *args, **kwargs)
Expand All @@ -316,6 +322,8 @@ def decorated(self, *args, **kwargs):


def node_pthreads(f):
assert callable(f)

@wraps(f)
def decorated(self, *args, **kwargs):
self.setup_node_pthreads()
Expand Down
13 changes: 13 additions & 0 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@


def wasm_simd(f):
assert callable(f)

@wraps(f)
def decorated(self, *args, **kwargs):
self.require_simd()
Expand All @@ -58,6 +60,9 @@ def decorated(self, *args, **kwargs):


def wasm_relaxed_simd(f):
assert callable(f)

@wraps(f)
def decorated(self):
if self.get_setting('MEMORY64') == 2:
self.skipTest('https://github.com/WebAssembly/binaryen/issues/4638')
Expand All @@ -70,6 +75,9 @@ def decorated(self):


def needs_non_trapping_float_to_int(f):
assert callable(f)

@wraps(f)
def decorated(self):
if self.is_wasm2js():
self.skipTest('wasm2js only supports MVP for now')
Expand Down Expand Up @@ -151,6 +159,9 @@ def decorated(f):

# Similar to also_with_wasmfs, but also enables the full JS API
def also_with_wasmfs_js(func):
assert callable(func)

@wraps(func)
def decorated(self):
func(self)
print('wasmfs')
Expand All @@ -166,6 +177,7 @@ def decorated(self):
def with_asyncify_and_jspi(f):
assert callable(f)

@wraps(f)
def metafunc(self, jspi):
if jspi:
self.set_setting('ASYNCIFY', 2)
Expand All @@ -186,6 +198,7 @@ def no_optimize(note=''):
def decorator(func):
assert callable(func)

@wraps(func)
def decorated(self):
if self.is_optimizing():
self.skipTest(note)
Expand Down
3 changes: 3 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ def with_both_compilers(f):


def wasmfs_all_backends(f):
assert callable(f)

@wraps(f)
def metafunc(self, backend):
self.set_setting('WASMFS')
self.emcc_args.append('-DWASMFS')
Expand Down

0 comments on commit 7e86721

Please sign in to comment.