Skip to content

Commit a5b003d

Browse files
authored
[esm-integration] Add a new core test mode and fix or disable all tests (#24288)
1 parent 8f1c0e9 commit a5b003d

File tree

10 files changed

+119
-22
lines changed

10 files changed

+119
-22
lines changed

.circleci/config.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,21 @@ jobs:
659659
steps:
660660
- run-tests-linux:
661661
test_targets: "instance"
662+
test-esm-integration:
663+
# We don't use `bionic` here since its too old to run recent node versions:
664+
# `/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found`
665+
executor: linux-python
666+
steps:
667+
- prepare-for-tests
668+
# The linux-python image uses /home/circleci rather than /root and jsvu
669+
# hardcodes /root into its launcher scripts so we need to reinstall v8.
670+
- run: rm -rf $HOME/.jsvu
671+
- install-v8
672+
- install-node-canary
673+
- run-tests:
674+
title: "esm-integration"
675+
test_targets: "esm-integration"
676+
- upload-test-results
662677
test-wasm2js1:
663678
environment:
664679
EMTEST_SKIP_NODE_CANARY: "1"
@@ -667,7 +682,7 @@ jobs:
667682
- run-tests-linux:
668683
test_targets: "wasm2js1"
669684
test-wasm64:
670-
# We don't use `bionic` here since its tool old to run recent node versions:
685+
# We don't use `bionic` here since its too old to run recent node versions:
671686
# `/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found`
672687
executor: linux-python
673688
steps:
@@ -811,10 +826,6 @@ jobs:
811826
core0.test_pthread_join_and_asyncify
812827
core0.test_async_ccall_promise_jspi*
813828
core0.test_cubescript_jspi
814-
esm_integration.test_fs_js_api*
815-
esm_integration.test_inlinejs3
816-
esm_integration.test_embind_val_basics
817-
esm_integration.test_undefined_main
818829
"
819830
# Run some basic tests with the minimum version of node that we currently
820831
# support in the generated code.
@@ -1142,6 +1153,9 @@ workflows:
11421153
- test-modularize-instance:
11431154
requires:
11441155
- build-linux
1156+
- test-esm-integration:
1157+
requires:
1158+
- build-linux
11451159
- test-browser-chrome
11461160
- test-browser-chrome-2gb:
11471161
requires:

site/source/docs/compiling/Modularized-Output.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ fix in future releses. Current limitations include:
138138
* The output of file_packager is not compatible so :ref:`emcc-preload-file` and
139139
:ref:`emcc-embed-file` do not work.
140140

141+
141142
Source Phase Imports (experimental)
142143
===================================
143144

@@ -167,5 +168,14 @@ This setting implicitly enables :ref:`export_es6` and sets :ref:`MODULARIZE` to
167168
``instance``. Because of this all the same limitations mentioned above for
168169
``-sMODULARIZE=intance`` apply.
169170

171+
Some additional limitations are:
172+
173+
- ``-pthread`` / :ref:`wasm_workers` are not yet supported.
174+
175+
- Setting :ref:`wasm` to ``0`` is not supported.
176+
177+
- Setting :ref:`wasm_async_compilation` to ``0`` is not supported.
178+
179+
170180
.. _Source phase imports: https://github.com/tc39/proposal-source-phase-imports
171181
.. _Wasm ESM integration: https://github.com/WebAssembly/esm-integration

test/common.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ def metafunc(self, with_minimal_runtime, *args, **kwargs):
522522
print('parameterize:minimal_runtime=%s' % with_minimal_runtime)
523523
assert self.get_setting('MINIMAL_RUNTIME') is None
524524
if with_minimal_runtime:
525-
if self.get_setting('MODULARIZE') == 'instance':
525+
if self.get_setting('MODULARIZE') == 'instance' or self.get_setting('WASM_ESM_INTEGRATION'):
526526
self.skipTest('MODULARIZE=instance is not compatible with MINIMAL_RUNTIME')
527527
self.set_setting('MINIMAL_RUNTIME', 1)
528528
# This extra helper code is needed to cleanly handle calls to exit() which throw
@@ -604,6 +604,7 @@ def can_do_standalone(self, impure=False):
604604
return self.is_wasm() and \
605605
self.get_setting('STACK_OVERFLOW_CHECK', 0) < 2 and \
606606
not self.get_setting('MINIMAL_RUNTIME') and \
607+
not self.get_setting('WASM_ESM_INTEGRATION') and \
607608
not self.get_setting('SAFE_HEAP') and \
608609
not any(a.startswith('-fsanitize=') for a in self.emcc_args)
609610

@@ -1138,6 +1139,8 @@ def require_wasm2js(self):
11381139
self.skipTest('wasm2js is not compatible with MEMORY64')
11391140
if self.is_2gb() or self.is_4gb():
11401141
self.skipTest('wasm2js does not support over 2gb of memory')
1142+
if self.get_setting('WASM_ESM_INTEGRATION'):
1143+
self.skipTest('wasm2js is not compatible with WASM_ESM_INTEGRATION')
11411144

11421145
def setup_nodefs_test(self):
11431146
self.require_node()
@@ -1160,6 +1163,8 @@ def setup_node_pthreads(self):
11601163
self.emcc_args += ['-Wno-pthreads-mem-growth', '-pthread']
11611164
if self.get_setting('MINIMAL_RUNTIME'):
11621165
self.skipTest('node pthreads not yet supported with MINIMAL_RUNTIME')
1166+
if self.get_setting('WASM_ESM_INTEGRATION'):
1167+
self.skipTest('pthreads not yet supported with WASM_ESM_INTEGRATION')
11631168
nodejs = self.get_nodejs()
11641169
self.js_engines = [nodejs]
11651170
self.node_args += shared.node_pthread_flags(nodejs)

test/core/test_demangle_stacks.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include <emscripten.h>
1010

11+
EM_JS_DEPS(deps, "$jsStackTrace");
12+
1113
namespace NameSpace {
1214
class Class {
1315
public:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
53827
1+
53860
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
27082
1+
27115
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
51877
1+
51910

test/test_core.py

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@ def decorated(self, *args, **kwargs):
6767
return decorator
6868

6969

70+
def no_esm_integration(note):
71+
assert not callable(note)
72+
73+
def decorator(f):
74+
assert callable(f)
75+
76+
@wraps(f)
77+
def decorated(self, *args, **kwargs):
78+
if self.get_setting('WASM_ESM_INTEGRATION'):
79+
self.skipTest(note)
80+
f(self, *args, **kwargs)
81+
return decorated
82+
83+
return decorator
84+
85+
7086
def wasm_simd(f):
7187
assert callable(f)
7288

@@ -189,6 +205,8 @@ def with_asyncify_and_jspi(f):
189205

190206
@wraps(f)
191207
def metafunc(self, jspi, *args, **kwargs):
208+
if self.get_setting('WASM_ESM_INTEGRATION'):
209+
self.skipTest('WASM_ESM_INTEGRATION is not compatible with ASYNCIFY')
192210
if jspi:
193211
self.set_setting('ASYNCIFY', 2)
194212
self.require_jspi()
@@ -208,6 +226,8 @@ def also_with_asyncify_and_jspi(f):
208226

209227
@wraps(f)
210228
def metafunc(self, asyncify, *args, **kwargs):
229+
if asyncify and self.get_setting('WASM_ESM_INTEGRATION'):
230+
self.skipTest('WASM_ESM_INTEGRATION is not compatible with ASYNCIFY')
211231
if asyncify == 2:
212232
self.set_setting('ASYNCIFY', 2)
213233
self.require_jspi()
@@ -437,6 +457,7 @@ def get_bullet_library(self, use_cmake):
437457
def test_hello_world(self):
438458
self.do_core_test('test_hello_world.c')
439459

460+
@no_esm_integration('WASM_ASYNC_COMPILATION=0')
440461
def test_wasm_synchronous_compilation(self):
441462
if self.get_setting('MODULARIZE') != 'instance':
442463
self.set_setting('STRICT_JS')
@@ -927,6 +948,7 @@ def test_longjmp(self):
927948
self.do_core_test('test_longjmp.c')
928949

929950
@no_sanitize('sanitizers do not support WASM_WORKERS')
951+
@no_esm_integration('WASM_ESM_INTEGRATION is not compatible with WASM_WORKERS')
930952
def test_longjmp_wasm_workers(self):
931953
self.do_core_test('test_longjmp.c', emcc_args=['-sWASM_WORKERS'])
932954

@@ -2008,7 +2030,11 @@ def test_em_js(self, args, force_c):
20082030
self.setup_node_pthreads()
20092031

20102032
self.do_core_test('test_em_js.cpp', force_c=force_c)
2011-
self.assertContained('no args returning int', read_file(self.output_name('test_em_js')))
2033+
if self.get_setting('WASM_ESM_INTEGRATION'):
2034+
js_out = 'test_em_js.support.mjs'
2035+
else:
2036+
js_out = self.output_name('test_em_js')
2037+
self.assertContained('no args returning int', read_file(js_out))
20122038

20132039
@no_wasm2js('test depends on WASM_BIGINT which is not compatible with wasm2js')
20142040
def test_em_js_i64(self):
@@ -2186,6 +2212,7 @@ def test_nothrow_new(self, args):
21862212
@no_lsan('LSan alters the memory size')
21872213
@no_4gb('depends on memory size')
21882214
@no_2gb('depends on memory size')
2215+
@no_esm_integration('external wasmMemory')
21892216
def test_module_wasm_memory(self):
21902217
self.emcc_args += ['--pre-js', test_file('core/test_module_wasm_memory.js')]
21912218
self.set_setting('IMPORTED_MEMORY')
@@ -6998,7 +7025,6 @@ def test_EXPORTED_RUNTIME_METHODS(self):
69987025

69997026
@also_with_minimal_runtime
70007027
@no_modularize_instance('uses dynCallLegacy')
7001-
@no_wasm64('not compatible with MEMORY64')
70027028
def test_dyncall_specific(self):
70037029
if self.get_setting('WASM_BIGINT') != 0 and not self.is_wasm2js():
70047030
# define DYNCALLS because this test does test calling them directly, and
@@ -7462,6 +7488,7 @@ def test_embind_negative_constants(self):
74627488
self.do_run_in_out_file_test('embind/test_negative_constants.cpp', emcc_args=['-lembind'])
74637489

74647490
@also_with_wasm_bigint
7491+
@no_esm_integration('embind is not compatible with WASM_ESM_INTEGRATION')
74657492
def test_embind_unsigned(self):
74667493
self.do_run_in_out_file_test('embind/test_unsigned.cpp', emcc_args=['-lembind'])
74677494

@@ -7637,6 +7664,7 @@ def test_embind_no_rtti_followed_by_rtti(self):
76377664
self.do_run(src, '418\ndotest returned: 42\n')
76387665

76397666
@no_sanitize('sanitizers do not support WASM_WORKERS')
7667+
@no_esm_integration('WASM_ESM_INTEGRATION is not compatible with WASM_WORKERS')
76407668
def test_embind_wasm_workers(self):
76417669
self.do_run_in_out_file_test('embind/test_embind_wasm_workers.cpp', emcc_args=['-lembind', '-sWASM_WORKERS'])
76427670

@@ -7812,6 +7840,7 @@ def test_embind_dylink_visibility_hidden(self):
78127840
self.do_runf('main.cpp', 'done\n', emcc_args=['--bind'])
78137841

78147842
@no_wasm2js('TODO: source maps in wasm2js')
7843+
@no_esm_integration('WASM_ESM_INTEGRATION is not compatible with dwarf output')
78157844
def test_dwarf(self):
78167845
self.emcc_args.append('-g')
78177846

@@ -8254,6 +8283,7 @@ def test_asyncify_lists(self, args, should_pass, response=None):
82548283
binary = read_binary(filename)
82558284
self.assertFalse(b'main' in binary)
82568285

8286+
@no_esm_integration('WASM_ESM_INTEGRATION is not compatible with ASYNCIFY')
82578287
@parameterized({
82588288
'normal': ([], True),
82598289
'ignoreindirect': (['-sASYNCIFY_IGNORE_INDIRECT'], False),
@@ -8645,7 +8675,10 @@ def test_environment(self):
86458675

86468676
def test(assert_returncode=0):
86478677
self.do_core_test('test_hello_world.c', assert_returncode=assert_returncode)
8648-
js = read_file(self.output_name('test_hello_world'))
8678+
if self.get_setting('WASM_ESM_INTEGRATION'):
8679+
js = read_file(self.output_name('test_hello_world.support'))
8680+
else:
8681+
js = read_file(self.output_name('test_hello_world'))
86498682
assert ('require(' in js) == ('node' in self.get_setting('ENVIRONMENT')), 'we should have require() calls only if node js specified'
86508683

86518684
for engine in config.JS_ENGINES:
@@ -8770,11 +8803,13 @@ def test_minimal_runtime_global_initializer(self):
87708803
self.do_runf('test_global_initializer.cpp', 't1 > t0: 1')
87718804

87728805
@no_wasm2js('wasm2js does not support PROXY_TO_PTHREAD (custom section support)')
8806+
@no_esm_integration('USE_OFFSET_CONVERTER')
87738807
def test_return_address(self):
87748808
self.set_setting('USE_OFFSET_CONVERTER')
87758809
self.do_runf('core/test_return_address.c', 'passed')
87768810

87778811
@no_wasm2js('TODO: sanitizers in wasm2js')
8812+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
87788813
@no_asan('-fsanitize-minimal-runtime cannot be used with ASan')
87798814
@no_lsan('-fsanitize-minimal-runtime cannot be used with LSan')
87808815
def test_ubsan_minimal_too_many_errors(self):
@@ -8784,6 +8819,7 @@ def test_ubsan_minimal_too_many_errors(self):
87848819
regex=True)
87858820

87868821
@no_wasm2js('TODO: sanitizers in wasm2js')
8822+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
87878823
@no_asan('-fsanitize-minimal-runtime cannot be used with ASan')
87888824
@no_lsan('-fsanitize-minimal-runtime cannot be used with LSan')
87898825
def test_ubsan_minimal_errors_same_place(self):
@@ -8798,6 +8834,7 @@ def test_ubsan_minimal_errors_same_place(self):
87988834
'fsanitize_overflow': (['-fsanitize=signed-integer-overflow'],),
87998835
})
88008836
@no_wasm2js('TODO: sanitizers in wasm2js')
8837+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
88018838
def test_ubsan_full_overflow(self, args):
88028839
self.emcc_args += args
88038840
self.do_runf(
@@ -8813,6 +8850,7 @@ def test_ubsan_full_overflow(self, args):
88138850
'fsanitize_return': (['-fsanitize=return'],),
88148851
})
88158852
@no_wasm2js('TODO: sanitizers in wasm2js')
8853+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
88168854
def test_ubsan_full_no_return(self, args):
88178855
self.emcc_args += ['-Wno-return-type'] + args
88188856
self.do_runf('core/test_ubsan_full_no_return.cpp',
@@ -8824,6 +8862,7 @@ def test_ubsan_full_no_return(self, args):
88248862
'fsanitize_shift': (['-fsanitize=shift'],),
88258863
})
88268864
@no_wasm2js('TODO: sanitizers in wasm2js')
8865+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
88278866
def test_ubsan_full_left_shift(self, args):
88288867
self.emcc_args += args
88298868
self.do_runf(
@@ -8840,6 +8879,7 @@ def test_ubsan_full_left_shift(self, args):
88408879
'dylink': (['-fsanitize=null', '-sMAIN_MODULE=2'],),
88418880
})
88428881
@no_wasm2js('TODO: sanitizers in wasm2js')
8882+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
88438883
def test_ubsan_full_null_ref(self, args):
88448884
if '-sMAIN_MODULE=2' in args:
88458885
self.check_dylink()
@@ -8856,6 +8896,7 @@ def test_ubsan_full_null_ref(self, args):
88568896
])
88578897

88588898
@no_wasm2js('TODO: sanitizers in wasm2js')
8899+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
88598900
def test_sanitize_vptr(self):
88608901
self.do_runf(
88618902
'core/test_sanitize_vptr.cpp',
@@ -8878,6 +8919,7 @@ def test_sanitize_vptr(self):
88788919
]),
88798920
})
88808921
@no_wasm2js('TODO: sanitizers in wasm2js')
8922+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
88818923
def test_ubsan_full_stack_trace(self, g_flag, expected_output):
88828924
if g_flag == '-gsource-map':
88838925
if self.is_wasm2js():
@@ -8892,6 +8934,7 @@ def test_ubsan_full_stack_trace(self, g_flag, expected_output):
88928934
assert_all=True, expected_output=expected_output)
88938935

88948936
@no_wasm2js('TODO: sanitizers in wasm2js')
8937+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
88958938
def test_ubsan_typeinfo_eq(self):
88968939
# https://github.com/emscripten-core/emscripten/issues/13330
88978940
src = r'''
@@ -8911,6 +8954,7 @@ def test_template_class_deduction(self):
89118954
self.do_core_test('test_template_class_deduction.cpp')
89128955

89138956
@no_wasm2js('TODO: ASAN in wasm2js')
8957+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
89148958
@no_safe_heap('asan does not work with SAFE_HEAP')
89158959
@no_wasm64('TODO: ASAN in memory64')
89168960
@no_2gb('asan doesnt support GLOBAL_BASE')
@@ -8931,6 +8975,7 @@ def test_asan_no_error(self, name):
89318975
@no_safe_heap('asan does not work with SAFE_HEAP')
89328976
@no_wasm64('TODO: ASAN in memory64')
89338977
@no_2gb('asan doesnt support GLOBAL_BASE')
8978+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
89348979
@parameterized({
89358980
'use_after_free_c': ('test_asan_use_after_free.c', [
89368981
'AddressSanitizer: heap-use-after-free on address',
@@ -9004,6 +9049,7 @@ def test_asan(self, name, expected_output, cflags=None):
90049049
@no_wasm2js('TODO: ASAN in wasm2js')
90059050
@no_wasm64('TODO: ASAN in memory64')
90069051
@no_2gb('asan doesnt support GLOBAL_BASE')
9052+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
90079053
def test_asan_js_stack_op(self):
90089054
self.emcc_args.append('-fsanitize=address')
90099055
self.set_setting('ALLOW_MEMORY_GROWTH')
@@ -9015,6 +9061,7 @@ def test_asan_js_stack_op(self):
90159061
@no_wasm2js('TODO: ASAN in wasm2js')
90169062
@no_wasm64('TODO: ASAN in memory64')
90179063
@no_2gb('asan doesnt support GLOBAL_BASE')
9064+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
90189065
def test_asan_api(self):
90199066
self.emcc_args.append('-fsanitize=address')
90209067
self.set_setting('INITIAL_MEMORY', '300mb')
@@ -9024,6 +9071,7 @@ def test_asan_api(self):
90249071
@no_wasm2js('TODO: ASAN in wasm2js')
90259072
@no_wasm64('TODO: ASAN in memory64')
90269073
@no_2gb('asan doesnt support GLOBAL_BASE')
9074+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
90279075
def test_asan_modularized_with_closure(self):
90289076
# the bug is that createModule() returns undefined, instead of the
90299077
# proper Promise object.
@@ -9038,6 +9086,7 @@ def test_asan_modularized_with_closure(self):
90389086

90399087
@no_asan('SAFE_HEAP cannot be used with ASan')
90409088
@no_2gb('asan doesnt support GLOBAL_BASE')
9089+
@no_esm_integration('sanitizers do not support WASM_ESM_INTEGRATION')
90419090
def test_safe_heap_user_js(self):
90429091
self.set_setting('SAFE_HEAP')
90439092
self.do_runf('core/test_safe_heap_user_js.c',
@@ -9429,6 +9478,7 @@ def test_Module_dynamicLibraries(self, args):
94299478

94309479
# Tests the emscripten_get_exported_function() API.
94319480
@also_with_minimal_runtime
9481+
@no_esm_integration('depends on wasmExports')
94329482
def test_get_exported_function(self):
94339483
self.set_setting('ALLOW_TABLE_GROWTH')
94349484
self.emcc_args += ['-lexports.js']

0 commit comments

Comments
 (0)