GNOME Bugzilla – Bug 703826
system.exit() expects conflicting number of arguments
Last modified: 2013-08-06 10:06:04 UTC
const System = imports.system; System.exit(0); produces ** (gjs:19889): CRITICAL **: gjs_parse_args: assertion `arg_location != NULL' failed JS_EvaluateScript() failed but no exception message? while const System = imports.system; System.exit(); produces JS ERROR: !!! Exception was: Error: Error invoking exit: Expected 1 arguments, got 0 JS ERROR: !!! message = '"Error invoking exit: Expected 1 arguments, got 0"' JS ERROR: !!! fileName = '"main.js"' JS ERROR: !!! lineNumber = '17' JS ERROR: !!! stack = '"@main.js:17 I think either the number of args should be 1 in the JS_DefineFunction() call on l.158 of system.c (https://git.gnome.org/browse/gjs/tree/modules/system.c#n158) or gjs_exit() shouldn't call gjs_parse_args() on l.116 (https://git.gnome.org/browse/gjs/tree/modules/system.c#n116). I don't know what your desired API for system.exit() is, so I didn't prepare a patch, but either way it's a one or two-line fix. Personally, the API with the exit code argument makes more sense to me.
Created attachment 250154 [details] [review] tests: Rename installed-tests/test to installed-tests/extra Since really the directory is extra stuff.
Created attachment 250155 [details] [review] modules/system: Fix system.exit See patch.
Created attachment 250156 [details] [review] tests: Add new installed-tests/scripts test mechanism The unit tests are not suitable for all sorts of tests; in particular, I can't test System.exit() from there since it loads all of the tests into one process. So this patch adds a new type of "scripts" test which is literally just a gjs script; if it exits successfully, the test passed.
Review of attachment 250155 [details] [review]: OK.
Created attachment 250224 [details] [review] tests: Add new installed-tests/scripts test mechanism Throw an explicit error if we fail to exit
Pretty confident in the small tests changes, we can always improve them later.