Skip to content

Commit 45d8735

Browse files
committed
Clean EXPORT_KEEPALIVE tests
1 parent 0a7e8ec commit 45d8735

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

src/settings.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,9 +997,6 @@ var EXPORT_ALL = false;
997997
// If true, we export the symbols that are present in JS onto the Module
998998
// object.
999999
// It only does Module['X'] = X;
1000-
//
1001-
// This only applies to MINIMAL_RUNTIME, where symbols aren't exported by
1002-
// default.
10031000
var EXPORT_KEEPALIVE = true;
10041001

10051002
// Remembers the values of these settings, and makes them accessible

test/test_other.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,23 +1313,18 @@ def test_export_keepalive(self):
13131313
EMSCRIPTEN_KEEPALIVE int libf1() { return 42; }
13141314
''')
13151315

1316-
create_file('main.js', '''
1317-
var Module = {
1318-
onRuntimeInitialized: function() {
1319-
console.log(Module._libf1 ? Module._libf1() : 'unexported');
1320-
}
1316+
create_file('pre.js', '''
1317+
Module.onRuntimeInitialized = () => {
1318+
console.log(Module._libf1 ? Module._libf1() : 'unexported');
13211319
};
13221320
''')
13231321

13241322
# By default, all kept alive functions should be exported.
1325-
self.emcc('main.c', ['--pre-js', 'main.js'], output_filename='test.js')
1326-
self.assertContained('42\n', self.run_js('test.js'))
1323+
self.do_runf('main.c', '42\n', emcc_args=['--pre-js', 'pre.js'])
13271324

13281325
# Ensures that EXPORT_KEEPALIVE=0 remove the exports
1329-
self.emcc('main.c', ['-sEXPORT_KEEPALIVE=0', '--pre-js', 'main.js'], output_filename='test.js')
1330-
self.assertContained('unexported', self.run_js('test.js'))
1326+
self.do_runf('main.c', 'unexported\n', emcc_args=['-sEXPORT_KEEPALIVE=0', '--pre-js', 'pre.js'])
13311327

1332-
@requires_node
13331328
def test_minimal_modularize_export_keepalive(self):
13341329
create_file('main.c', r'''
13351330
#include <emscripten.h>
@@ -1342,16 +1337,14 @@ def write_js_main():
13421337
write_file('main.js', f'{runtime}\nModule().then((mod) => console.log(mod._libf1()));')
13431338

13441339
# By default, no symbols should be exported when using MINIMAL_RUNTIME.
1345-
self.emcc('main.c', ['-sMODULARIZE=1', '-sMINIMAL_RUNTIME=2'], output_filename='test.js')
1340+
self.emcc('main.c', ['-sMODULARIZE=1', '-sMINIMAL_RUNTIME=2', '-sASSERTIONS=0'], output_filename='test.js')
13461341
write_js_main()
1347-
output = self.expect_fail(config.NODE_JS + ['main.js'])
1348-
self.assertContained('TypeError: mod._libf1 is not a function', output)
1342+
self.assertContained('TypeError: mod._libf1 is not a function', self.run_js('main.js', assert_returncode=NON_ZERO))
13491343

13501344
# Ensures that EXPORT_KEEPALIVE=1 exports the symbols.
1351-
self.emcc('main.c', ['-sMODULARIZE=1', '-sMINIMAL_RUNTIME=2', '-sEXPORT_KEEPALIVE=1'], output_filename='test.js')
1345+
self.emcc('main.c', ['-sMODULARIZE=1', '-sMINIMAL_RUNTIME=2', '-sEXPORT_KEEPALIVE=1', '-sASSERTIONS=0'], output_filename='test.js')
13521346
write_js_main()
1353-
output = self.run_process(config.NODE_JS + ['main.js'], stdout=PIPE, stderr=PIPE)
1354-
self.assertContained('42\n', output.stdout)
1347+
self.assertContained('42\n', self.run_js('main.js'))
13551348

13561349
def test_minimal_runtime_export_all_modularize(self):
13571350
"""This test ensures that MODULARIZE and EXPORT_ALL work simultaneously.

0 commit comments

Comments
 (0)