Skip to content

Commit 9152fca

Browse files
authored
Return non-zero on error from preprocessor.js (#24873)
Without this change errors in, for example, `shell.html` were reported to stdout but not detected as fatal errors.
1 parent 857e7ff commit 9152fca

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/utility.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export function errorOccured() {
8888

8989
export function error(msg, lineNo) {
9090
abortExecution = true;
91+
process.exitCode = 1;
9192
printErr(`error: ${errorPrefix(lineNo)}${msg}`);
9293
}
9394

test/test_other.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11306,6 +11306,15 @@ def test_node_js_pthread_module(self, es6):
1130611306
ret = self.run_js('workerLoader.js')
1130711307
self.assertContained('hello, world!\ndone\n', ret)
1130811308

11309+
@crossplatform
11310+
def test_html_preprocess_error(self):
11311+
create_file('shell.html', '''
11312+
#error this is an error
11313+
{{{ SCRIPT }}}
11314+
''')
11315+
err = self.expect_fail([EMCC, '-o', 'out.html', test_file('hello_world.c'), '--shell-file=shell.html'])
11316+
self.assertContained('error: shell.html:2: #error this is an error', err)
11317+
1130911318
@no_windows('node system() does not seem to work, see https://github.com/emscripten-core/emscripten/pull/10547')
1131011319
@requires_node
1131111320
def test_system_node_js(self):

0 commit comments

Comments
 (0)