JavaScript shell exits with a zero status when program is terminated

RESOLVED FIXED in mozilla12

Status

()

Core
JavaScript Engine
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: jimb, Unassigned)

Tracking

unspecified
mozilla12
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
If the JavaScript shell runs a file (via -f) whose code terminates (that is, execution returns an error, but no exception is set), the shell exits with a zero status. It should only exit with a zero status when all files specified by -f and scripts given using -e complete successfully.

For example:

$ cat foo.js
terminate();
$ cat bar.js
print("Hi, from bar!");
$ js -f foo.js; echo $?
0
$ js -f bar.js; echo $?
Hi, from bar!
0
$ js -f foo.js -f bar.js; echo $?
Hi, from bar!
0
$ 

(Here, 'terminate' is the function defined by the patch in bug 717417.)
(Reporter)

Updated

6 years ago
Flags: in-testsuite+
OS: Linux → All
Hardware: x86_64 → All
Target Milestone: --- → mozilla13
(Reporter)

Comment 1

6 years ago
Created attachment 591676 [details] [diff] [review]
Make the shell exit with EXITCODE_RUNTIME_ERROR when code is terminated.

In js/src/jit-test/jit_test.py, add an 'exitstatus' jit-test cookie
attribute (and rename test.error to test.expect_error). Mark tests that
terminate with their expected termination code.

Clean up TMFLAGS comments.
Attachment #591676 - Flags: review?(jorendorff)
Comment on attachment 591676 [details] [diff] [review]
Make the shell exit with EXITCODE_RUNTIME_ERROR when code is terminated.

Thanks!

I'd even be OK with a bigger change in behavior here, where a single failing -e or -f causes Process to return false, and its caller checks the return value and bails out. Separate bug if so.
Attachment #591676 - Flags: review?(jorendorff) → review+
(Reporter)

Comment 3

6 years ago
(In reply to Jason Orendorff [:jorendorff] from comment #2)
> I'd even be OK with a bigger change in behavior here, where a single failing
> -e or -f causes Process to return false, and its caller checks the return
> value and bails out. Separate bug if so.

Actually, every caller of Process already checks gExitCode, so that is the behavior this patch brings about.
(Reporter)

Comment 4

6 years ago
try: https://tbpl.mozilla.org/?tree=Try&rev=6914ca5efbd0
(Reporter)

Comment 5

6 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/ab3edf81a46f
Status: NEW → ASSIGNED
https://hg.mozilla.org/mozilla-central/rev/ab3edf81a46f
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: mozilla13 → mozilla12
You need to log in before you can comment on or make changes to this bug.