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>
This commit is contained in:
parent
3d9c40783f
commit
1fcdc60ca0
@ -222,7 +222,7 @@ shell_introspection_init (void)
|
||||
{
|
||||
|
||||
g_irepository_prepend_search_path (MUTTER_TYPELIB_DIR);
|
||||
g_irepository_prepend_search_path (GNOME_SHELL_PKGLIBDIR);
|
||||
g_irepository_prepend_search_path (SHELL_TYPELIB_DIR);
|
||||
|
||||
/* We need to explicitly add the directories where the private libraries are
|
||||
* installed to the GIR's library path, so that they can be found at runtime
|
||||
|
@ -45,6 +45,11 @@ install_data('gnome-shell-extension-prefs',
|
||||
install_dir: bindir
|
||||
)
|
||||
|
||||
typelib_cflags = [
|
||||
'-DMUTTER_TYPELIB_DIR="@0@"'.format(mutter_typelibdir),
|
||||
'-DSHELL_TYPELIB_DIR="@0@"'.format(pkglibdir),
|
||||
]
|
||||
|
||||
gnome_shell_cflags = [
|
||||
'-DCLUTTER_ENABLE_EXPERIMENTAL_API',
|
||||
'-DCOGL_ENABLE_EXPERIMENTAL_API',
|
||||
@ -248,9 +253,7 @@ libshell_gir = gnome.generate_gir(libshell,
|
||||
)
|
||||
|
||||
executable('gnome-shell', 'main.c',
|
||||
c_args: gnome_shell_cflags + [
|
||||
'-DMUTTER_TYPELIB_DIR="@0@"'.format(mutter_typelibdir)
|
||||
],
|
||||
c_args: gnome_shell_cflags + typelib_cflags,
|
||||
dependencies: gnome_shell_deps + [libshell_dep, libst_dep, mutter_dep],
|
||||
include_directories: [conf_inc, st_inc, include_directories('tray')],
|
||||
build_rpath: mutter_typelibdir,
|
||||
@ -276,8 +279,9 @@ executable('gnome-shell-perf-helper', 'shell-perf-helper.c', js_resources,
|
||||
install: true
|
||||
)
|
||||
|
||||
executable('run-js-test', 'run-js-test.c',
|
||||
run_test = executable('run-js-test', 'run-js-test.c',
|
||||
dependencies: [mutter_dep, mtk_dep, gdk_pixbuf_dep, gio_dep, gi_dep, gjs_dep],
|
||||
c_args: typelib_cflags,
|
||||
include_directories: [conf_inc],
|
||||
link_with: libshell,
|
||||
build_rpath: mutter_typelibdir,
|
||||
|
@ -61,6 +61,9 @@ main(int argc, char **argv)
|
||||
global = shell_global_get ();
|
||||
js_context = _shell_global_get_gjs_context (global);
|
||||
|
||||
g_irepository_prepend_search_path (MUTTER_TYPELIB_DIR);
|
||||
g_irepository_prepend_search_path (SHELL_TYPELIB_DIR);
|
||||
|
||||
/* prepare command line arguments */
|
||||
if (!gjs_context_define_string_array (js_context, "ARGV",
|
||||
argc - 2, (const char**)argv + 2,
|
||||
|
@ -1,12 +1,3 @@
|
||||
testconf = configuration_data()
|
||||
testconf.set('MUTTER_TYPELIB_DIR', mutter_typelibdir)
|
||||
testconf.set('srcdir', meson.current_source_dir())
|
||||
run_test = configure_file(
|
||||
input: 'run-test.sh.in',
|
||||
output: 'run-test.sh',
|
||||
configuration: testconf
|
||||
)
|
||||
|
||||
mutter_tests_datadir = mutter_test_dep.get_variable('tests_datadir')
|
||||
dbusrunnerconf = configuration_data()
|
||||
dbusrunnerconf.set('MUTTER_TEST_PKGDATADIR', mutter_tests_datadir)
|
||||
@ -18,6 +9,16 @@ dbus_runner = configure_file(
|
||||
configuration: dbusrunnerconf,
|
||||
)
|
||||
|
||||
gvc_typelib_path = fs.parent(libgvc.get_variable('libgvc_gir')[1].full_path())
|
||||
shell_typelib_path = fs.parent(libshell_gir[1].full_path())
|
||||
st_typelib_path = fs.parent(libst_gir[1].full_path())
|
||||
|
||||
unit_testenv = environment()
|
||||
unit_testenv.set('GNOME_SHELL_DATADIR', data_builddir)
|
||||
unit_testenv.append('GI_TYPELIB_PATH', gvc_typelib_path, separator: ':')
|
||||
unit_testenv.append('GI_TYPELIB_PATH', shell_typelib_path, separator: ':')
|
||||
unit_testenv.append('GI_TYPELIB_PATH', st_typelib_path, separator: ':')
|
||||
|
||||
unit_tests = [
|
||||
'highlighter',
|
||||
'injectionManager',
|
||||
@ -34,6 +35,7 @@ foreach test : unit_tests
|
||||
test(test, run_test,
|
||||
args: 'unit/@0@.js'.format(test),
|
||||
suite: 'unit',
|
||||
env: unit_testenv,
|
||||
workdir: meson.current_source_dir())
|
||||
endforeach
|
||||
|
||||
@ -53,7 +55,6 @@ shell_tests = [
|
||||
},
|
||||
]
|
||||
|
||||
gvc_typelib_path = fs.parent(libgvc.get_variable('libgvc_gir')[1].full_path())
|
||||
libgvc_path = fs.parent(libgvc.get_variable('libgvc').full_path())
|
||||
|
||||
background_file = join_paths(meson.current_source_dir(), 'data', 'background.png')
|
||||
|
@ -1,45 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
usage() {
|
||||
echo >&2 "Usage run-test.sh [-v|--verbose] <test_js>..."
|
||||
exit 1
|
||||
}
|
||||
|
||||
tests=
|
||||
verbose=false
|
||||
debug=
|
||||
for arg in $@ ; do
|
||||
case $arg in
|
||||
-g|--debug)
|
||||
debug="libtool --mode=execute gdb --args"
|
||||
;;
|
||||
-v|--verbose)
|
||||
verbose=true
|
||||
;;
|
||||
-*)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
tests="$tests $arg"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
builddir=`dirname $0`
|
||||
builddir=`cd $builddir && pwd`
|
||||
srcdir=@srcdir@
|
||||
srcdir=`cd $srcdir && pwd`
|
||||
|
||||
GI_TYPELIB_PATH="$GI_TYPELIB_PATH${GI_TYPELIB_PATH:+:}@MUTTER_TYPELIB_DIR@:$builddir/../src:$builddir/../src/st:$builddir/../subprojects/gvc"
|
||||
GJS_PATH="$srcdir:$srcdir/../js:$builddir/../js"
|
||||
GJS_DEBUG_OUTPUT=stderr
|
||||
$verbose || GJS_DEBUG_TOPICS="JS ERROR;JS LOG"
|
||||
GNOME_SHELL_TESTSDIR="$srcdir/"
|
||||
GNOME_SHELL_JS="$srcdir/../js"
|
||||
GNOME_SHELL_DATADIR="$builddir/../data"
|
||||
|
||||
export GI_TYPELIB_PATH GJS_PATH GJS_DEBUG_OUTPUT GJS_DEBUG_TOPICS GNOME_SHELL_TESTSDIR GNOME_SHELL_JS GNOME_SHELL_DATADIR LD_PRELOAD
|
||||
|
||||
for test in $tests ; do
|
||||
$debug $builddir/../src/run-js-test $test || exit $?
|
||||
done
|
Loading…
x
Reference in New Issue
Block a user