@@ -1326,23 +1326,31 @@ def test_export_keepalive(self):
13261326 self.do_runf('main.c', 'unexported\n', emcc_args=['-sEXPORT_KEEPALIVE=0', '--pre-js', 'pre.js'])
13271327
13281328 def test_minimal_modularize_export_keepalive(self):
1329+ self.set_setting('MODULARIZE')
1330+ self.set_setting('MINIMAL_RUNTIME')
1331+
13291332 create_file('main.c', r'''
13301333 #include <emscripten.h>
13311334 EMSCRIPTEN_KEEPALIVE int libf1() { return 42; }
13321335 ''')
13331336
1334- # With MINIMAL_RUNTIME, the module isn't exported.
13351337 def write_js_main():
1338+ """
1339+ With MINIMAL_RUNTIME, the module instantiation function isn't exported neither as a UMD nor as an ES6 module.
1340+ Thus, it's impossible to use `require` or `import`.
1341+
1342+ This function simply appends the instantiation code to the generated code.
1343+ """
13361344 runtime = read_file('test.js')
13371345 write_file('main.js', f'{runtime}\nModule().then((mod) => console.log(mod._libf1()));')
13381346
13391347 # By default, no symbols should be exported when using MINIMAL_RUNTIME.
1340- self.emcc('main.c', ['-sMODULARIZE=1', '-sMINIMAL_RUNTIME=2', '-sASSERTIONS=0' ], output_filename='test.js')
1348+ self.emcc('main.c', [], output_filename='test.js')
13411349 write_js_main()
13421350 self.assertContained('TypeError: mod._libf1 is not a function', self.run_js('main.js', assert_returncode=NON_ZERO))
13431351
13441352 # Ensures that EXPORT_KEEPALIVE=1 exports the symbols.
1345- self.emcc('main.c', ['-sMODULARIZE=1', '-sMINIMAL_RUNTIME=2', '- sEXPORT_KEEPALIVE=1', '-sASSERTIONS=0 '], output_filename='test.js')
1353+ self.emcc('main.c', ['-sEXPORT_KEEPALIVE=1'], output_filename='test.js')
13461354 write_js_main()
13471355 self.assertContained('42\n', self.run_js('main.js'))
13481356
0 commit comments