27 Commits

Author SHA1 Message Date
Florian Müllner
f4c46647e6 run-test: Filter out SYSTEM_EXIT errors
Calling `System.exit()` isn't an error, and there isn't much
value in logging a "Exit with code 0" message.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3599>
2025-01-28 12:38:30 +00:00
Florian Müllner
546f3d65f7 run-test: Always use returned status code if possible
gjs_context_eval_module_file() is a convenience method for

 - register the module (load and parse)
 - evaluate the module (run)

The first can fail, but has no notion of status code; the
second will always set a valid code if provided (either as
returned by the module, or set by gjs itself).

Doing those two steps separately allows us to explicitly
handle failures to register the module, so that we can then
return the original status code from evaluating the module.

That means that if evaluating the module "fails" with a
`GJS_ERROR_SYSTEM_EXIT` error (because it was terminated
with `System.exit()`), we now return the correct status
code instead of `EXIT_FAILURE`.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3599>
2025-01-28 12:38:30 +00:00
Florian Müllner
d192fc984f 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>
2025-01-28 12:38:30 +00:00
Florian Müllner
f42c2d7371 run-test: Switch to new argv API
It's a bit nicer to use than manually defining the legacy ARGV
array.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3599>
2025-01-28 12:38:30 +00:00
Florian Müllner
699c7c1b2c run-test: Check argc before using argv
We skip the filename argument when defining ARGV before actually
checking that it was provided.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3599>
2025-01-28 12:38:30 +00:00
Florian Müllner
e7691bd3df run-tests: Add missing newlines in error messages
Unlike the various g_message() macros, the g_print() functions do
not add an implicit newline at the end of the message.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3599>
2025-01-28 12:38:30 +00:00
Florian Müllner
68fe35d1a2 run-test: Use g_autoptr/autofree
While we don't really care about freeing memory before leaving
main, it doesn't hurt and is good practice anyway.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3599>
2025-01-28 12:38:30 +00:00
Florian Müllner
696bd09d18 run-test: Fix coding style errors
The original code was likely copied from gjs' console code at the
time, which means that its coding style sneaked in.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3599>
2025-01-28 12:38:30 +00:00
Florian Müllner
1fcdc60ca0 tests: Drop wrapper script for unit test runner
We build a small run-js-test executable so tests run in a
similar environment as gnome-shell, and then wrap it with
a generated script that provides environment variables like
GI_TYPELIB_PATH.

This is more complicated than it needs to be, we can just as
well set up the typelib search path from the runner and pass
in the environment via meson.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3164>
2024-05-21 13:42:28 +00:00
Evan Welsh
26fa1046a3 tests: Load unit tests as modules
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
b798efcc1d tests: Use gjs_context_eval_file to evaluate test scripts
GJS provides utilities to run scripts given a filename, using those
utilities we can remove most of the logic implementing file loading.

Additionally the REPL logic does not make much sense for a test
runner and is unused, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Florian Müllner
8ac5be95d3 tests: Don't initialize Clutter
Clutter's backend code depends on MetaBackend now, which makes it
impossible to initialize without resorting to private mutter API.

Luckily we only need Clutter for interactive tests which are broken
anyway, as Clutter.main() and friends were removed a while ago.

So for now, get at least unit tests working again by simply the
unnecessary Clutter initialization.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/691
2019-08-27 15:30:51 +03:00
Jonas Ådahl
32ea7d763a Don't set clutters 'window-scaling-factor' property
It doesn't exist anymore.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-04-07 22:30:35 +08:00
Philip Chimento
dc110db4e0 tests: Destroy GjsContext before exit
This will be required in the upcoming version of GJS.

https://bugzilla.gnome.org/show_bug.cgi?id=775374
2016-12-09 18:50:39 -08:00
Owen W. Taylor
c4584c20dc run-js-test: fix running in hi-dpi mode 2016-06-30 14:17:19 -04:00
Jasper St. Pierre
39d3ff6caf run-js-test: Remove old code to shove X11 events through 2015-02-11 16:31:26 -08:00
Bastien Nocera
ebc15e60a8 bluetooth: Remove GnomeBluetoothApplet hacks
https://bugzilla.gnome.org/show_bug.cgi?id=719341
2013-11-26 18:53:18 +01:00
Florian Müllner
1735f28f5a Remove use of deprecated g_type_init () ...
... and bump GObject requirement accordingly.

https://bugzilla.gnome.org/show_bug.cgi?id=686318
2012-10-17 22:49:32 +02:00
Jasper St. Pierre
3ce9ad05b3 run-js-test: GC twice after running a test
When running with Valgrind, this helps us ensure that we're managing
memory correctly. We need to GC twice as finalizing an object in the
sweep can unroot objects which were already marked. Technically, it
could be that we'll need to GC more than twice, but GCing twice should
hopefully last us for now.

https://bugzilla.gnome.org/show_bug.cgi?id=678737
2012-06-24 19:20:48 -04:00
Florian Müllner
fcee7f2f3a run-js-test: Do not use the default stage
This was left out in commit faff0738eb.
2011-12-16 00:18:17 +01:00
Jasper St. Pierre
4bb48e56d2 Drop deprecated g_thread_init call
GThread will automatically initialize at program start now.

https://bugzilla.gnome.org/show_bug.cgi?id=662011
2011-10-18 16:13:55 -04:00
Dan Winship
885e194c25 run-js-test: fix
Needs to explicitly initialize the ShellGlobal now

https://bugzilla.gnome.org/show_bug.cgi?id=649631
2011-09-05 12:23:59 -04:00
Dan Winship
0907f030b4 tests: fix up typelib include paths
The js modules have so many imports back and forth that it's pretty
much guaranteed that if you import even one of them, you'll end up
importing all of them, including ui.status.bluetooth and
ui.status.network. So fix up the typelib include paths the same way
gnome-shell-jhbuild does, so we can find everything.

https://bugzilla.gnome.org/show_bug.cgi?id=650298
2011-07-27 09:29:03 -04:00
Dan Winship
7921954a31 environment: move more init stuff here from main.js
Move some more environment-initializationy stuff from main.js to
environment.js, and be more careful about not importing shell JS
modules until after the environment has been fully patched.

Change gnome-shell-plugin to call Environment.init() before
Main.start(); this means that Environment.init() now runs before any
shell JS modules (besides environment itself) have been imported.

Make run-js-test create a ShellGlobal and use its js_context, so that
the shell_global_set_property_mutable() stuff in Environment.init()
will work correctly in tests as well.

https://bugzilla.gnome.org/show_bug.cgi?id=649203
2011-05-16 14:56:27 -04:00
Owen W. Taylor
d3703516d9 Fix handling of clutter_init() failures
clutter_init() fails under normal circumstances like
being unable to open a display connection, so it shouldn't
be handled with g_error() producing a core dump.

Clutter consistently produces an error message when
clutter_init() fails, so we don't need to print out any
error message.

https://bugzilla.gnome.org/show_bug.cgi?id=643910
2011-03-13 14:29:47 -04:00
Colin Walters
bdebaa986b Silence -Werror for other clutter_init callers 2011-03-13 14:16:54 -04:00
Owen W. Taylor
c98103ffc8 Add run-js-test executable to run tests
ST makes use of GTK+ for input methods and for icon themes; therefore
we have need to initialize GTK+ in order to test these parts of Clutter.

Instead of LD_PRELOADING our module, use a separately compiled executable
that links to the UI components in GNOME Shell, initializes Clutter and
GTK+ and hooks them together.

Getting all the symbols from St and the GUI components exported for
use via GJS requires a bit of contortion: we need to actually link the
St convenience library into a shared library and link the executable
to that since there is no way with libtool to take a convenience library
and put all its symbols into an executable --whole-archive style.

https://bugzilla.gnome.org/show_bug.cgi?id=633657
2010-11-12 17:36:20 -05:00