Skip to content

Commit

Permalink
onRuntimeInitializeFailed -> onAbort (#5357)
Browse files Browse the repository at this point in the history
  • Loading branch information
buu700 committed Jul 5, 2017
1 parent 80826bc commit 47875d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 2 additions & 6 deletions src/postamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,6 @@ function run(args) {
}
#endif

Module['onRuntimeInitializeFailed'] = undefined;

if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']();

if (Module['_main'] && shouldRunNow) Module['callMain'](args);
Expand Down Expand Up @@ -318,10 +316,8 @@ Module['exit'] = Module.exit = exit;
var abortDecorators = [];

function abort(what) {
if (Module['onRuntimeInitializeFailed']) {
var onRuntimeInitializeFailed = Module['onRuntimeInitializeFailed'];
Module['onRuntimeInitializeFailed'] = undefined;
onRuntimeInitializeFailed(what);
if (Module['onAbort']) {
Module['onAbort'](what);
}

#if USE_PTHREADS
Expand Down
6 changes: 3 additions & 3 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -3195,18 +3195,18 @@ def test_warn_unaligned(self):
assert 'emcc: warning: unaligned store' in output[1], output[1]
assert '@line 11 "src.cpp"' in output[1], output[1]

def test_runtime_initialize_failed(self):
def test_on_abort(self):
cmd = [PYTHON, EMCC, path_from_root('tests', 'hello_world.c'), '-s', 'WASM=1']

self.clear()
proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
output, err = proc.communicate()

expectedOutput = 'runtime init failed'
expectedOutput = "Module['onAbort'] was called"

os.remove('a.out.wasm')
f = open('a.out.js', 'a')
f.write("Module['onRuntimeInitializeFailed'] = function () { console.log('%s') }" % expectedOutput)
f.write("Module['onAbort'] = function () { console.log('%s') }" % expectedOutput)
f.close()

devnull = open(os.devnull, 'w')
Expand Down

0 comments on commit 47875d6

Please sign in to comment.