aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/postamble.js7
-rwxr-xr-xtests/runner.py2
2 files changed, 8 insertions, 1 deletions
diff --git a/src/postamble.js b/src/postamble.js
index 388d0127..971568cd 100644
--- a/src/postamble.js
+++ b/src/postamble.js
@@ -2,6 +2,13 @@
// === Auto-generated postamble setup entry stuff ===
Module.callMain = function callMain(args) {
+ args = args || [];
+
+ if (!calledInit) {
+ initRuntime();
+ calledInit = true;
+ }
+
var argc = args.length+1;
function pad() {
for (var i = 0; i < {{{ QUANTUM_SIZE }}}-1; i++) {
diff --git a/tests/runner.py b/tests/runner.py
index 23935656..0a8e0209 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -9975,7 +9975,7 @@ f.close()
if no_initial_run:
# Calling main later should still work, filesystem etc. must be set up.
- src = open(os.path.join(self.get_dir(), 'a.out.js')).read() + '\n_main();\n';
+ src = open(os.path.join(self.get_dir(), 'a.out.js')).read() + '\nModule.callMain();\n';
open(os.path.join(self.get_dir(), 'a.out.js'), 'w').write(src)
assert 'hello from main' in run_js(os.path.join(self.get_dir(), 'a.out.js')), 'main should print when called manually'