Skip to content

Commit 8dc404a

Browse files
authored
Use @wraps on all test decorators (#22377)
Without this the decorated function doesn't mirror properties of the underlying tests, which was breaking things like `@crossplatform`. See #18163
1 parent c93788f commit 8dc404a

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

test/common.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ def decorated(self, *args, **kwargs):
247247
def requires_node(func):
248248
assert callable(func)
249249

250+
@wraps(func)
250251
def decorated(self, *args, **kwargs):
251252
self.require_node()
252253
return func(self, *args, **kwargs)
@@ -257,6 +258,7 @@ def decorated(self, *args, **kwargs):
257258
def requires_node_canary(func):
258259
assert callable(func)
259260

261+
@wraps(func)
260262
def decorated(self, *args, **kwargs):
261263
self.require_node_canary()
262264
return func(self, *args, **kwargs)
@@ -267,6 +269,7 @@ def decorated(self, *args, **kwargs):
267269
def requires_wasm64(func):
268270
assert callable(func)
269271

272+
@wraps(func)
270273
def decorated(self, *args, **kwargs):
271274
self.require_wasm64()
272275
return func(self, *args, **kwargs)
@@ -277,6 +280,7 @@ def decorated(self, *args, **kwargs):
277280
def requires_wasm_eh(func):
278281
assert callable(func)
279282

283+
@wraps(func)
280284
def decorated(self, *args, **kwargs):
281285
self.require_wasm_eh()
282286
return func(self, *args, **kwargs)
@@ -287,6 +291,7 @@ def decorated(self, *args, **kwargs):
287291
def requires_wasm_exnref(func):
288292
assert callable(func)
289293

294+
@wraps(func)
290295
def decorated(self, *args, **kwargs):
291296
self.require_wasm_exnref()
292297
return func(self, *args, **kwargs)
@@ -297,6 +302,7 @@ def decorated(self, *args, **kwargs):
297302
def requires_v8(func):
298303
assert callable(func)
299304

305+
@wraps(func)
300306
def decorated(self, *args, **kwargs):
301307
self.require_v8()
302308
return func(self, *args, **kwargs)
@@ -316,6 +322,8 @@ def decorated(self, *args, **kwargs):
316322

317323

318324
def node_pthreads(f):
325+
assert callable(f)
326+
319327
@wraps(f)
320328
def decorated(self, *args, **kwargs):
321329
self.setup_node_pthreads()

test/test_core.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141

4242

4343
def wasm_simd(f):
44+
assert callable(f)
45+
4446
@wraps(f)
4547
def decorated(self, *args, **kwargs):
4648
self.require_simd()
@@ -58,6 +60,9 @@ def decorated(self, *args, **kwargs):
5860

5961

6062
def wasm_relaxed_simd(f):
63+
assert callable(f)
64+
65+
@wraps(f)
6166
def decorated(self):
6267
if self.get_setting('MEMORY64') == 2:
6368
self.skipTest('https://github.com/WebAssembly/binaryen/issues/4638')
@@ -70,6 +75,9 @@ def decorated(self):
7075

7176

7277
def needs_non_trapping_float_to_int(f):
78+
assert callable(f)
79+
80+
@wraps(f)
7381
def decorated(self):
7482
if self.is_wasm2js():
7583
self.skipTest('wasm2js only supports MVP for now')
@@ -151,6 +159,9 @@ def decorated(f):
151159

152160
# Similar to also_with_wasmfs, but also enables the full JS API
153161
def also_with_wasmfs_js(func):
162+
assert callable(func)
163+
164+
@wraps(func)
154165
def decorated(self):
155166
func(self)
156167
print('wasmfs')
@@ -166,6 +177,7 @@ def decorated(self):
166177
def with_asyncify_and_jspi(f):
167178
assert callable(f)
168179

180+
@wraps(f)
169181
def metafunc(self, jspi):
170182
if jspi:
171183
self.set_setting('ASYNCIFY', 2)
@@ -186,6 +198,7 @@ def no_optimize(note=''):
186198
def decorator(func):
187199
assert callable(func)
188200

201+
@wraps(func)
189202
def decorated(self):
190203
if self.is_optimizing():
191204
self.skipTest(note)

test/test_other.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ def with_both_compilers(f):
111111

112112

113113
def wasmfs_all_backends(f):
114+
assert callable(f)
115+
116+
@wraps(f)
114117
def metafunc(self, backend):
115118
self.set_setting('WASMFS')
116119
self.emcc_args.append('-DWASMFS')

0 commit comments

Comments
 (0)