@@ -2850,21 +2850,19 @@ def test_get_proc_address_error_message(self):
2850
2850
})
2851
2851
def test_prepost(self, no_initial_run, run_dep):
2852
2852
create_file('pre.js', '''
2853
- var Module = {
2854
- preRun: () => out('pre-run'),
2855
- postRun: () => out('post-run')
2853
+ Module = {
2854
+ " preRun" : () => out('pre-run'),
2855
+ " postRun" : () => out('post-run')
2856
2856
};
2857
2857
''')
2858
2858
2859
- self.run_process([EMCC, test_file('hello_world.c'), '--pre-js', 'pre.js', '-sWASM_ASYNC_COMPILATION=0'])
2860
- self.assertContained('pre-run\nhello, world!\npost-run\n', self.run_js('a.out.js'))
2859
+ self.do_runf('hello_world.c', 'pre-run\nhello, world!\npost-run\n', cflags=['--pre-js', 'pre.js', '-sWASM_ASYNC_COMPILATION=0'])
2861
2860
2862
2861
# addRunDependency during preRun should prevent main, and post-run from
2863
2862
# running.
2864
2863
with open('pre.js', 'a') as f:
2865
- f.write('Module.preRun = () => { out("add-dep"); addRunDependency(); }\n')
2866
- self.run_process([EMCC, test_file('hello_world.c'), '--pre-js', 'pre.js', '-sWASM_ASYNC_COMPILATION=0'])
2867
- output = self.run_js('a.out.js')
2864
+ f.write('Module["preRun"] = () => { out("add-dep"); addRunDependency("dep"); }\n')
2865
+ output = self.do_runf('hello_world.c', cflags=['--pre-js', 'pre.js', '-sRUNTIME_DEBUG', '-sWASM_ASYNC_COMPILATION=0', '-O2', '--closure=1'])
2868
2866
self.assertContained('add-dep\n', output)
2869
2867
self.assertNotContained('hello, world!\n', output)
2870
2868
self.assertNotContained('post-run\n', output)
@@ -2874,21 +2872,20 @@ def test_prepost(self, no_initial_run, run_dep):
2874
2872
if no_initial_run:
2875
2873
args += ['-sINVOKE_RUN=0']
2876
2874
if run_dep:
2877
- create_file('pre.js', 'Module. preRun = () => addRunDependency("test");')
2875
+ create_file('pre.js', 'Module[" preRun"] = () => addRunDependency("test");')
2878
2876
create_file('post.js', 'removeRunDependency("test");')
2879
2877
args += ['--pre-js', 'pre.js', '--post-js', 'post.js']
2880
2878
2881
- self.run_process([EMCC, test_file('hello_world.c')] + args)
2882
- output = self.run_js('a.out.js')
2879
+ output = self.do_runf('hello_world.c', cflags=args)
2883
2880
self.assertContainedIf('hello, world!', output, not no_initial_run)
2884
2881
2885
2882
if no_initial_run:
2886
2883
# Calling main later should still work, filesystem etc. must be set up.
2887
2884
print('call main later')
2888
- src = read_file('a.out .js')
2885
+ src = read_file('hello_world .js')
2889
2886
src += '\nout("callMain -> " + Module.callMain());\n'
2890
- create_file('a.out .js', src)
2891
- self.assertContained('hello, world!\ncallMain -> 0\n', self.run_js('a.out .js'))
2887
+ create_file('hello_world .js', src)
2888
+ self.assertContained('hello, world!\ncallMain -> 0\n', self.run_js('hello_world .js'))
2892
2889
2893
2890
def test_prepost2(self):
2894
2891
create_file('pre.js', 'Module.preRun = () => out("pre-run");')
0 commit comments