0 | 0 |
--- a/tests/runner.py
|
1 | 1 |
+++ b/tests/runner.py
|
2 | |
@@ -98,6 +98,8 @@
|
|
2 |
@@ -97,6 +97,8 @@
|
3 | 3 |
|
4 | 4 |
EMTEST_SKIP_SLOW = os.getenv('EMTEST_SKIP_SLOW')
|
5 | 5 |
|
|
8 | 8 |
EMTEST_LACKS_NATIVE_CLANG = os.getenv('EMTEST_LACKS_NATIVE_CLANG')
|
9 | 9 |
|
10 | 10 |
EMTEST_VERBOSE = int(os.getenv('EMTEST_VERBOSE', '0')) or shared.DEBUG
|
11 | |
@@ -171,6 +173,17 @@
|
|
11 |
@@ -170,6 +172,17 @@
|
12 | 12 |
return lambda f: f
|
13 | 13 |
|
14 | 14 |
|
|
32 | 32 |
from tools.shared import EMCC, EMXX, EMAR, EMRANLIB, PYTHON, FILE_PACKAGER, WINDOWS, EM_BUILD_VERBOSE
|
33 | 33 |
from tools.shared import CLANG_CC, CLANG_CXX, LLVM_AR, LLVM_DWARFDUMP
|
34 | 34 |
from runner import RunnerCore, path_from_root, is_slow_test, ensure_dir, disabled, make_executable
|
35 | |
-from runner import env_modify, no_mac, no_windows, requires_native_clang, chdir, with_env_modify
|
|
35 |
-from runner import env_modify, no_mac, no_windows, requires_native_clang, with_env_modify
|
36 | 36 |
-from runner import create_test_file, parameterized, NON_ZERO, node_pthreads
|
37 | |
+from runner import env_modify, no_mac, no_windows, requires_closure_compiler, requires_native_clang, chdir, with_env_modify
|
|
37 |
+from runner import env_modify, no_mac, no_windows, requires_closure_compiler, requires_native_clang, with_env_modify
|
38 | 38 |
+from runner import create_test_file, parameterized, NON_ZERO, EMTEST_LACKS_CLOSURE_COMPILER, node_pthreads
|
39 | 39 |
from tools import shared, building, utils
|
40 | 40 |
import jsrun
|
41 | 41 |
import clang_native
|
42 | |
@@ -1062,7 +1062,7 @@
|
|
42 |
@@ -1085,7 +1085,7 @@
|
43 | 43 |
create_test_file('in.txt', 'abcdef\nghijkl')
|
44 | 44 |
run_test()
|
45 | 45 |
building.emcc(path_from_root('tests', 'module', 'test_stdin.c'),
|
|
48 | 48 |
run_test()
|
49 | 49 |
|
50 | 50 |
def test_ungetc_fscanf(self):
|
51 | |
@@ -2056,7 +2056,8 @@
|
|
51 |
@@ -2079,7 +2079,8 @@
|
52 | 52 |
test_cases += test_cases_without_utf8
|
53 | 53 |
test_cases.extend([(args[:] + ['-s', 'DYNAMIC_EXECUTION=0']) for args in test_cases])
|
54 | 54 |
# closure compiler doesn't work with DYNAMIC_EXECUTION=0
|
|
58 | 58 |
for args in test_cases:
|
59 | 59 |
print(args)
|
60 | 60 |
self.clear()
|
61 | |
@@ -2364,6 +2365,7 @@
|
|
61 |
@@ -2398,6 +2399,7 @@
|
62 | 62 |
print(output)
|
63 | 63 |
self.assertLess(output.count('Cannot enlarge memory arrays'), 5)
|
64 | 64 |
|
|
66 | 66 |
def test_module_exports_with_closure(self):
|
67 | 67 |
# This test checks that module.export is retained when JavaScript is minified by compiling with --closure 1
|
68 | 68 |
# This is important as if module.export is not present the Module object will not be visible to node.js
|
69 | |
@@ -4671,10 +4673,11 @@
|
|
69 |
@@ -4705,10 +4707,11 @@
|
70 | 70 |
test(['-s', 'ASSERTIONS=0'], 120000) # we don't care about code size with assertions
|
71 | 71 |
test(['-O1'], 91000)
|
72 | 72 |
test(['-O2'], 46000)
|
|
82 | 82 |
|
83 | 83 |
def test_no_browser(self):
|
84 | 84 |
BROWSER_INIT = 'var Browser'
|
85 | |
@@ -5999,7 +6002,7 @@
|
|
85 |
@@ -6033,7 +6036,7 @@
|
86 | 86 |
'--post-js', path_from_root('tests', 'return64bit', 'testbindend.js'),
|
87 | 87 |
'-s', 'DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[$dynCall]',
|
88 | 88 |
'-s', 'EXPORTED_FUNCTIONS=[_test_return64]', '-o', 'test.js', '-O2',
|
|
91 | 91 |
|
92 | 92 |
# Simple test program to load the test.js binding library and call the binding to the
|
93 | 93 |
# C function returning the 64 bit long.
|
94 | |
@@ -6588,7 +6591,7 @@
|
|
94 |
@@ -6622,7 +6625,7 @@
|
95 | 95 |
|
96 | 96 |
# test debug info and debuggability of JS output
|
97 | 97 |
def test_binaryen_debug(self):
|
|
100 | 100 |
(['-O0'], False, False, False, True, False),
|
101 | 101 |
(['-O0', '-g1'], False, False, False, True, False),
|
102 | 102 |
(['-O0', '-g2'], True, False, False, True, False), # in -g2+, we emit -g to asm2wasm so function names are saved
|
103 | |
@@ -6598,9 +6601,11 @@
|
|
103 |
@@ -6632,9 +6635,11 @@
|
104 | 104 |
(['-O2'], False, False, True, False, False),
|
105 | 105 |
(['-O2', '-g1'], False, False, True, True, False),
|
106 | 106 |
(['-O2', '-g'], True, True, False, True, False),
|
|
115 | 115 |
print(args, expect_dash_g, expect_emit_text)
|
116 | 116 |
try_delete('a.out.wat')
|
117 | 117 |
cmd = [EMCC, path_from_root('tests', 'hello_world.cpp')] + args
|
118 | |
@@ -7177,7 +7182,7 @@
|
|
118 |
@@ -7212,7 +7217,7 @@
|
119 | 119 |
cmd += ['--memory-init-file', '1']
|
120 | 120 |
if debug_enabled:
|
121 | 121 |
cmd += ['-g']
|
|
124 | 124 |
cmd += ['--closure', '1']
|
125 | 125 |
if not wasm_enabled:
|
126 | 126 |
cmd += ['-s', 'WASM=0']
|
127 | |
@@ -7283,6 +7288,7 @@
|
|
127 |
@@ -7318,6 +7323,7 @@
|
128 | 128 |
assert_aliases_match('MAXIMUM_MEMORY', 'WASM_MEM_MAX', '16777216', ['-s', 'ALLOW_MEMORY_GROWTH'])
|
129 | 129 |
assert_aliases_match('MAXIMUM_MEMORY', 'BINARYEN_MEM_MAX', '16777216', ['-s', 'ALLOW_MEMORY_GROWTH'])
|
130 | 130 |
|
|
132 | 132 |
def test_IGNORE_CLOSURE_COMPILER_ERRORS(self):
|
133 | 133 |
create_test_file('pre.js', r'''
|
134 | 134 |
// make closure compiler very very angry
|
135 | |
@@ -7310,6 +7316,7 @@
|
136 | |
proc = test(check=True, extra=['-s', 'IGNORE_CLOSURE_COMPILER_ERRORS=1'])
|
|
135 |
@@ -7345,6 +7351,7 @@
|
|
136 |
proc = test(check=True, extra=['-s', 'IGNORE_CLOSURE_COMPILER_ERRORS'])
|
137 | 137 |
self.assertNotContained(WARNING, proc.stderr)
|
138 | 138 |
|
139 | 139 |
+ @requires_closure_compiler
|
140 | 140 |
def test_closure_full_js_library(self):
|
141 | 141 |
# test for closure errors in the entire JS library
|
142 | 142 |
# We must ignore various types of errors that are expected in this situation, as we
|
143 | |
@@ -7321,6 +7328,7 @@
|
144 | |
self.run_process([EMCC, path_from_root('tests', 'hello_world.c'), '-O1', '--closure', '1', '-g1', '-s', 'INCLUDE_FULL_LIBRARY=1', '-s', 'USE_WEBGPU=1', '-s', 'ERROR_ON_UNDEFINED_SYMBOLS=0'])
|
|
143 |
@@ -7356,6 +7363,7 @@
|
|
144 |
self.run_process([EMCC, path_from_root('tests', 'hello_world.c'), '-O1', '--closure', '1', '-g1', '-s', 'INCLUDE_FULL_LIBRARY', '-s', 'USE_WEBGPU', '-s', 'ERROR_ON_UNDEFINED_SYMBOLS=0'])
|
145 | 145 |
|
146 | 146 |
# Tests --closure-args command line flag
|
147 | 147 |
+ @requires_closure_compiler
|
148 | 148 |
def test_closure_externs(self):
|
149 | 149 |
self.run_process([EMCC, path_from_root('tests', 'hello_world.c'), '--closure', '1', '--pre-js', path_from_root('tests', 'test_closure_externs_pre_js.js'), '--closure-args', '--externs "' + path_from_root('tests', 'test_closure_externs.js') + '"'])
|
150 | 150 |
|
151 | |
@@ -7469,11 +7477,12 @@
|
|
151 |
@@ -7504,11 +7512,12 @@
|
152 | 152 |
self.assertIdentical(normal, tiny)
|
153 | 153 |
self.assertIdentical(normal, huge)
|
154 | 154 |
|
|
163 | 163 |
})
|
164 | 164 |
def test_EM_ASM_ES6(self, args):
|
165 | 165 |
create_test_file('src.cpp', r'''
|
166 | |
@@ -8129,9 +8138,10 @@
|
|
166 |
@@ -8164,9 +8173,10 @@
|
167 | 167 |
|
168 | 168 |
self.run_process([PYTHON, path_from_root('tests', 'gen_many_js_functions.py'), 'library_long.js', 'main_long.c'])
|
169 | 169 |
for wasm in [[], ['-s', 'WASM=0']]:
|
|
177 | 177 |
args = [EMCC, '-O3', '--js-library', 'library_long.js', 'main_long.c', '-o', 'a.html'] + wasm + closure
|
178 | 178 |
print(' '.join(args))
|
179 | 179 |
self.run_process(args)
|
180 | |
@@ -8178,15 +8188,16 @@
|
|
180 |
@@ -8213,15 +8223,16 @@
|
181 | 181 |
ret = self.run_process(config.NODE_JS + ['a.out.js'], stdout=PIPE).stdout
|
182 | 182 |
self.assertContained('hello, world!\n', ret)
|
183 | 183 |
|
|
197 | 197 |
})
|
198 | 198 |
def test_emscripten_license(self, expect_license, args):
|
199 | 199 |
# fastcomp does not support the new license flag
|
200 | |
@@ -8221,7 +8232,10 @@
|
|
200 |
@@ -8256,7 +8267,10 @@
|
201 | 201 |
num_times_export_is_referenced = output.count('thisIsAFunctionExportedFromAsmJsOrWasmWithVeryLongFunction')
|
202 | 202 |
self.assertEqual(num_times_export_is_referenced, 1)
|
203 | 203 |
|
|
209 | 209 |
for opt in [['-O2'], ['-O3'], ['-Os']]:
|
210 | 210 |
test(['-s', 'WASM=0'], closure, opt)
|
211 | 211 |
test(['-s', 'WASM_ASYNC_COMPILATION=0'], closure, opt)
|
212 | |
@@ -8263,7 +8277,7 @@
|
213 | |
'-s', 'NO_FILESYSTEM=1',
|
|
212 |
@@ -8298,7 +8312,7 @@
|
|
213 |
'-s', 'NO_FILESYSTEM',
|
214 | 214 |
'--output_eol', 'linux',
|
215 | 215 |
'-Oz',
|
216 | 216 |
- '--closure', '1',
|
|
218 | 218 |
'-DNDEBUG',
|
219 | 219 |
'-ffast-math']
|
220 | 220 |
|
221 | |
@@ -8752,6 +8766,7 @@
|
|
221 |
@@ -8787,6 +8801,7 @@
|
222 | 222 |
# otherwise in such a trivial program).
|
223 | 223 |
self.assertLess(no, 0.95 * yes)
|
224 | 224 |
|
|
226 | 226 |
def test_INCOMING_MODULE_JS_API(self):
|
227 | 227 |
def test(args):
|
228 | 228 |
self.run_process([EMCC, path_from_root('tests', 'hello_world.c'), '-O3', '--closure', '1'] + args)
|
229 | |
@@ -9075,11 +9090,14 @@
|
|
229 |
@@ -9110,11 +9125,14 @@
|
230 | 230 |
|
231 | 231 |
def test_warning_flags(self):
|
232 | 232 |
self.run_process([EMCC, '-c', '-o', 'hello.o', path_from_root('tests', 'hello_world.c')])
|
|
244 | 244 |
|
245 | 245 |
# -w to suppress warnings
|
246 | 246 |
stderr = self.run_process(cmd + ['-w'], stderr=PIPE).stderr
|
247 | |
@@ -9090,12 +9108,14 @@
|
|
247 |
@@ -9125,12 +9143,14 @@
|
248 | 248 |
self.assertNotContained('warning', stderr)
|
249 | 249 |
|
250 | 250 |
# with -Werror should fail
|
|
262 | 262 |
+ self.assertContained('emcc: warning: disabling closure because debug info was requested [-Wemcc]', stderr)
|
263 | 263 |
|
264 | 264 |
# check that `-Werror=foo` also enales foo
|
265 | |
stderr = self.expect_fail(cmd + ['-Werror=legacy-settings', '-s', 'TOTAL_MEMORY=1'])
|
266 | |
@@ -9312,6 +9332,7 @@
|
|
265 |
stderr = self.expect_fail(cmd + ['-Werror=legacy-settings', '-s', 'TOTAL_MEMORY'])
|
|
266 |
@@ -9347,6 +9367,7 @@
|
267 | 267 |
self.assertContained('INITIAL_MEMORY must be less than 2GB due to current spec limitations', stderr)
|
268 | 268 |
|
269 | 269 |
# Verifies that warning messages that Closure outputs are recorded to console
|
|
271 | 271 |
def test_closure_warnings(self):
|
272 | 272 |
proc = self.run_process([EMCC, path_from_root('tests', 'test_closure_warning.c'), '-O3', '--closure', '1', '-s', 'CLOSURE_WARNINGS=quiet'], stderr=PIPE)
|
273 | 273 |
self.assertNotContained('WARNING', proc.stderr)
|
274 | |
@@ -9725,6 +9746,7 @@
|
|
274 |
@@ -9756,6 +9777,7 @@
|
275 | 275 |
self.assertContained('hello, world!', self.run_js('a.out.js'))
|
276 | 276 |
|
277 | 277 |
# Test that Closure prints out clear readable error messages when there are errors.
|
|
279 | 279 |
def test_closure_errors(self):
|
280 | 280 |
err = self.expect_fail([EMCC, path_from_root('tests', 'closure_error.c'), '-O2', '--closure', '1'])
|
281 | 281 |
lines = err.split('\n')
|
282 | |
@@ -9743,16 +9765,19 @@
|
|
282 |
@@ -9774,16 +9796,19 @@
|
283 | 283 |
self.assertNotEqual(idx1, idx2)
|
284 | 284 |
|
285 | 285 |
# Make sure that --cpuprofiler compiles with --closure 1
|
|
298 | 298 |
+ @requires_closure_compiler
|
299 | 299 |
def test_threadprofiler_closure(self):
|
300 | 300 |
# TODO: Enable '-s', 'CLOSURE_WARNINGS=error' in the following, but that has currently regressed.
|
301 | |
self.run_process([EMCC, path_from_root('tests', 'hello_world.c'), '-O2', '-s', 'USE_PTHREADS=1', '--closure', '1', '--threadprofiler'])
|
|
301 |
self.run_process([EMCC, path_from_root('tests', 'hello_world.c'), '-O2', '-s', 'USE_PTHREADS', '--closure', '1', '--threadprofiler'])
|
302 | 302 |
--- a/tests/test_core.py
|
303 | 303 |
+++ b/tests/test_core.py
|
304 | 304 |
@@ -22,10 +22,10 @@
|
|
314 | 314 |
import clang_native
|
315 | 315 |
|
316 | 316 |
# decorators for limiting which modes a test can run in
|
317 | |
@@ -260,7 +260,7 @@
|
|
317 |
@@ -261,7 +261,7 @@
|
318 | 318 |
|
319 | 319 |
# Use closure in some tests for some additional coverage
|
320 | 320 |
def maybe_closure(self):
|
|
323 | 323 |
self.emcc_args += ['--closure', '1']
|
324 | 324 |
return True
|
325 | 325 |
return False
|
326 | |
@@ -1781,7 +1781,7 @@
|
|
326 |
@@ -1779,7 +1779,7 @@
|
327 | 327 |
# needs to flush stdio streams
|
328 | |
self.set_setting('EXIT_RUNTIME', 1)
|
|
328 |
self.set_setting('EXIT_RUNTIME')
|
329 | 329 |
|
330 | 330 |
- if self.run_name == 'asm2':
|
331 | 331 |
+ if self.run_name == 'asm2' and not EMTEST_LACKS_CLOSURE_COMPILER:
|
332 | 332 |
self.emcc_args += ['--closure', '1'] # Use closure here for some additional coverage
|
333 | 333 |
self.do_runf(path_from_root('tests', 'emscripten_get_now.cpp'), 'Timer resolution is good')
|
334 | 334 |
|
335 | |
@@ -4723,7 +4723,7 @@
|
|
335 |
@@ -4729,7 +4729,7 @@
|
336 | 336 |
self.banned_js_engines = [config.SPIDERMONKEY_ENGINE] # closure can generate variables called 'gc', which pick up js shell stuff
|
337 | 337 |
if self.maybe_closure(): # Use closure here, to test we don't break FS stuff
|
338 | 338 |
self.emcc_args = [x for x in self.emcc_args if x != '-g'] # ensure we test --closure 1 --memory-init-file 1 (-g would disable closure)
|
|
341 | 341 |
print('closure 2')
|
342 | 342 |
self.emcc_args += ['--closure', '2'] # Use closure 2 here for some additional coverage
|
343 | 343 |
return self.skipTest('TODO: currently skipped because CI runs out of memory running Closure in this test!')
|
344 | |
@@ -5082,7 +5082,7 @@
|
|
344 |
@@ -5091,7 +5091,7 @@
|
345 | 345 |
self.emcc_args += ['-lnodefs.js']
|
346 | |
self.set_setting('SYSCALL_DEBUG', 1)
|
|
346 |
self.set_setting('SYSCALL_DEBUG')
|
347 | 347 |
self.do_runf(path_from_root('tests', 'fs', 'test_nodefs_rw.c'), 'success')
|
348 | 348 |
- if '-g' not in self.emcc_args:
|
349 | 349 |
+ if '-g' not in self.emcc_args and not EMTEST_LACKS_CLOSURE_COMPILER:
|
350 | 350 |
print('closure')
|
351 | 351 |
self.emcc_args += ['--closure', '1']
|
352 | 352 |
self.do_runf(path_from_root('tests', 'fs', 'test_nodefs_rw.c'), 'success')
|
353 | |
@@ -5687,7 +5687,7 @@
|
|
353 |
@@ -5688,7 +5688,7 @@
|
354 | 354 |
def test_cubescript(self):
|
355 | 355 |
# uses register keyword
|
356 | 356 |
self.emcc_args += ['-std=c++03', '-Wno-dynamic-class-memaccess']
|
|
359 | 359 |
self.emcc_args += ['--closure', '1'] # Use closure here for some additional coverage
|
360 | 360 |
|
361 | 361 |
self.emcc_args = [x for x in self.emcc_args if x != '-g'] # remove -g, so we have one test without it by default
|
362 | |
@@ -6219,7 +6219,7 @@
|
|
362 |
@@ -6220,7 +6220,7 @@
|
363 | 363 |
self.set_setting('EXPORTED_FUNCTIONS', ['_get_int', '_get_float', '_get_bool', '_get_string', '_print_int', '_print_float', '_print_bool', '_print_string', '_multi', '_pointer', '_call_ccall_again', '_malloc'])
|
364 | 364 |
self.do_run_in_out_file_test('tests', 'core', 'test_ccall.cpp')
|
365 | 365 |
|
|
368 | 368 |
print('with closure')
|
369 | 369 |
self.emcc_args += ['--closure', '1']
|
370 | 370 |
self.do_run_in_out_file_test('tests', 'core', 'test_ccall.cpp')
|
371 | |
@@ -6833,7 +6833,7 @@
|
|
371 |
@@ -6827,7 +6827,7 @@
|
372 | 372 |
})
|
373 | 373 |
@sync
|
374 | 374 |
def test_webidl(self, mode, allow_memory_growth):
|
|
376 | 376 |
+ if self.run_name == 'asm2' and not EMTEST_LACKS_CLOSURE_COMPILER:
|
377 | 377 |
self.emcc_args += ['--closure', '1', '-g1'] # extra testing
|
378 | 378 |
# avoid closure minified names competing with our test code in the global name space
|
379 | |
self.set_setting('MODULARIZE', 1)
|
380 | |
@@ -7117,6 +7117,7 @@
|
|
379 |
self.set_setting('MODULARIZE')
|
|
380 |
@@ -7111,6 +7111,7 @@
|
381 | 381 |
self.assertLessEqual(start_wat_addr, dwarf_addr)
|
382 | 382 |
self.assertLessEqual(dwarf_addr, end_wat_addr)
|
383 | 383 |
|
|
385 | 385 |
def test_modularize_closure_pre(self):
|
386 | 386 |
# test that the combination of modularize + closure + pre-js works. in that mode,
|
387 | 387 |
# closure should not minify the Module object in a way that the pre-js cannot use it.
|
388 | |
@@ -7143,10 +7144,11 @@
|
|
388 |
@@ -7137,10 +7138,11 @@
|
389 | 389 |
self.emcc_args.append('-g')
|
390 | 390 |
self.emcc_args += ['-DRUN_FROM_JS_SHELL']
|
391 | 391 |
self.do_run_in_out_file_test('tests', 'emscripten_log', 'emscripten_log.cpp')
|
|
401 | 401 |
|
402 | 402 |
def test_float_literals(self):
|
403 | 403 |
self.do_run_in_out_file_test('tests', 'test_float_literals.cpp')
|
404 | |
@@ -7996,6 +7998,7 @@
|
|
404 |
@@ -8001,6 +8003,7 @@
|
405 | 405 |
|
406 | 406 |
@no_safe_heap('asan does not work with SAFE_HEAP')
|
407 | 407 |
@no_wasm2js('TODO: ASAN in wasm2js')
|
408 | 408 |
+ @requires_closure_compiler
|
409 | 409 |
def test_asan_modularized_with_closure(self):
|
410 | |
self.emcc_args.append('-sMODULARIZE=1')
|
411 | |
self.emcc_args.append('-sEXPORT_NAME="createModule"')
|
|
410 |
self.emcc_args.append('-fsanitize=address')
|
|
411 |
self.set_setting('MODULARIZE')
|