run-test: Split out module evaluation
The gjs API is slightly odd, in that explicit calls to `System.exit()` are treated as errors, regardless of the passed status code. Before addressing this, split out the module evaluation code into a separate function to separate it from the main logic. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3599>
This commit is contained in:
parent
f42c2d7371
commit
d192fc984f
@ -36,6 +36,18 @@
|
|||||||
#include "shell-global.h"
|
#include "shell-global.h"
|
||||||
#include "shell-global-private.h"
|
#include "shell-global-private.h"
|
||||||
|
|
||||||
|
static int
|
||||||
|
eval_module (GjsContext *js_context,
|
||||||
|
const char *filename,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
uint8_t code;
|
||||||
|
bool success = gjs_context_eval_module_file (js_context, filename, &code, error);
|
||||||
|
if (!success)
|
||||||
|
code = 1;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -77,13 +89,9 @@ main (int argc, char **argv)
|
|||||||
title = g_filename_display_basename (filename);
|
title = g_filename_display_basename (filename);
|
||||||
g_set_prgname (title);
|
g_set_prgname (title);
|
||||||
|
|
||||||
/* evaluate the script */
|
code = eval_module (js_context, filename, &error);
|
||||||
bool success = gjs_context_eval_module_file (js_context, filename, &code, &error);
|
if (error)
|
||||||
if (!success)
|
|
||||||
{
|
|
||||||
g_printerr ("%s\n", error->message);
|
g_printerr ("%s\n", error->message);
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
gjs_context_gc (js_context);
|
gjs_context_gc (js_context);
|
||||||
gjs_context_gc (js_context);
|
gjs_context_gc (js_context);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user