From fb3642149a5f0bb17e139ff166c446de4e8e90fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Wed, 24 Feb 2021 14:58:58 +0100 Subject: [PATCH] tests: Split client and JS tests This gives each suite a longer time and keeps things separate. Suggested in https://gitlab.gnome.org/GNOME/geary/-/merge_requests/670 --- test/meson.build | 34 +++++++++++++++++++++ test/test-client.vala | 7 ----- test/test-js.vala | 69 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 test/test-js.vala diff --git a/test/meson.build b/test/meson.build index dd1ce688..8adfd81a 100644 --- a/test/meson.build +++ b/test/meson.build @@ -101,6 +101,20 @@ test_client_sources = [ geary_resources ] +test_js_sources = [ + 'test-case.vala', + 'test-js.vala', + + 'client/components/components-web-view-test-case.vala', + + 'js/components-page-state-test.vala', + 'js/composer-page-state-test.vala', + 'js/conversation-page-state-test.vala', + + geary_compiled_schema, + geary_resources +] + test_integration_sources = [ 'test-case.vala', 'test-integration.vala', @@ -151,6 +165,21 @@ test_client_bin = executable('test-client', build_rpath: client_build_dir, ) +test_js_dependencies = [ + client_internal_dep, + vala_unit_dep, +] +test_js_dependencies += client_dependencies + +test_js_bin = executable('test-js', + test_js_sources + libmock_sources, + dependencies: test_js_dependencies, + include_directories: config_h_dir, + vala_args: geary_vala_args, + c_args: geary_c_args, + build_rpath: client_build_dir, +) + # Integration tests test_integration_bin = executable('test-integration', @@ -178,3 +207,8 @@ test( test_client_bin, depends: [ client_lib, web_process ] ) +test( + 'js-tests', + test_js_bin, + depends: [ client_lib, web_process ] +) diff --git a/test/test-client.vala b/test/test-client.vala index 08949b4c..f93ddc92 100644 --- a/test/test-client.vala +++ b/test/test-client.vala @@ -62,18 +62,11 @@ int main(string[] args) { client.add_suite(new Util.Email.Test().suite); client.add_suite(new Util.JS.Test().suite); - TestSuite js = new TestSuite("js"); - - js.add_suite(new Components.PageStateTest().suite); - js.add_suite(new Composer.PageStateTest().suite); - js.add_suite(new ConversationPageStateTest().suite); - /* * Run the tests */ TestSuite root = TestSuite.get_root(); root.add_suite(client); - root.add_suite(js); int ret = -1; Idle.add(() => { diff --git a/test/test-js.vala b/test/test-js.vala new file mode 100644 index 00000000..998ff10c --- /dev/null +++ b/test/test-js.vala @@ -0,0 +1,69 @@ +/* + * Copyright 2016-2017 Michael Gratton + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + + +int main(string[] args) { + /* + * Set env vars right up front to avoid weird bugs + */ + + // Use the memory GSettings DB so we a) always start with default + // values, and b) don't persist any changes made during a test + Environment.set_variable("GSETTINGS_BACKEND", "memory", true); + + // Let GSettings know where to find the dev schema + Environment.set_variable("GSETTINGS_SCHEMA_DIR", _GSETTINGS_DIR, true); + + /* + * Initialise all the things. + */ + + // Ensure things like e.g. GLib's formatting routines uses a + // well-known UTF-8-based locale rather ASCII. Would like to use + // C.UTF-8 here, but currently only Debian et al and Fedora ship + // it, and as of Fedora 32 they disagree on collation order for + // non-ASCII chars. + GLib.Intl.setlocale(LocaleCategory.ALL, "en_US.UTF-8"); + + Gtk.init(ref args); + Test.init(ref args); + + IconFactory.init(GLib.File.new_for_path(_SOURCE_ROOT_DIR)); + Geary.RFC822.init(); + Geary.HTML.init(); + Geary.Logging.init(); + if (GLib.Test.verbose()) { + GLib.Log.set_writer_func(Geary.Logging.default_log_writer); + Geary.Logging.log_to(GLib.stdout); + } + + /* + * Hook up all tests into appropriate suites + */ + + TestSuite js = new TestSuite("js"); + + js.add_suite(new Components.PageStateTest().suite); + js.add_suite(new Composer.PageStateTest().suite); + js.add_suite(new ConversationPageStateTest().suite); + + /* + * Run the tests + */ + TestSuite root = TestSuite.get_root(); + root.add_suite(js); + + int ret = -1; + Idle.add(() => { + ret = Test.run(); + Gtk.main_quit(); + return false; + }); + + Gtk.main(); + return ret; +}