2021-02-24 14:58:58 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright 2016-2017 Michael Gratton <mike@vee.net>
|
|
|
|
|
*
|
|
|
|
|
* 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
|
2025-12-07 01:21:41 +01:00
|
|
|
Environment.set_variable("GSETTINGS_SCHEMA_DIR", Config.GSETTINGS_DIR, true);
|
2021-02-24 14:58:58 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Initialise all the things.
|
|
|
|
|
*/
|
|
|
|
|
|
2025-07-02 14:32:07 +02:00
|
|
|
GLib.Intl.setlocale(LocaleCategory.ALL, "C.UTF-8");
|
2021-02-24 14:58:58 +01:00
|
|
|
|
|
|
|
|
Gtk.init(ref args);
|
|
|
|
|
Test.init(ref args);
|
|
|
|
|
|
2025-12-07 01:21:41 +01:00
|
|
|
IconFactory.init(GLib.File.new_for_path(Config.SOURCE_ROOT_DIR));
|
2021-02-24 14:58:58 +01:00
|
|
|
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");
|
|
|
|
|
|
Adapt vala-unit and tests to GLib 2.70 and later
`GLib.TestSuite` is a special type of object, as it doesn't actually
have an associated copy function or a reference/unreference function.
In practice, that actually means there's no way to actually have 2
strong references to such an object, or to copy it somehow. Due to the
way GObject properties in Vala work, that means you can't really use
them either.
Ever since vala commit 5f0a146f65, this got reflected properly in the
internally maintained GLib VAPI (as people were experiencing double
frees otherwise), but it was added only conditionally for GLib 2.70 or
later. In practice, that means you only get vala compiler issues if you
(impliclty) set `--target-glib=2.70` (or a later version).
To fix this for vala-unit and our own Geary tests, this commit changes
the `ValaUnit.TestCase` class to only allow "stealing" the strong
reference to the `GLib.TestSuite`, rather than somehowing allowing
people to hold a weak reference, and by also making it a protected field
rather than a property.
Since this changes the API of ValaUnit, we also bump the version. In
general though, I hope people aren't using ValaUnit externally, since
these types of API/ABI breaks can happen with Vala libraries.
Link: https://gitlab.gnome.org/GNOME/vala/-/commit/5f0a146f65673379fc84c3cd8e6bca826ffad96f
2025-12-07 10:09:15 +01:00
|
|
|
js.add_suite(new Components.PageStateTest().steal_suite());
|
|
|
|
|
js.add_suite(new Composer.PageStateTest().steal_suite());
|
|
|
|
|
js.add_suite(new ConversationPageStateTest().steal_suite());
|
2021-02-24 14:58:58 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Run the tests
|
|
|
|
|
*/
|
Adapt vala-unit and tests to GLib 2.70 and later
`GLib.TestSuite` is a special type of object, as it doesn't actually
have an associated copy function or a reference/unreference function.
In practice, that actually means there's no way to actually have 2
strong references to such an object, or to copy it somehow. Due to the
way GObject properties in Vala work, that means you can't really use
them either.
Ever since vala commit 5f0a146f65, this got reflected properly in the
internally maintained GLib VAPI (as people were experiencing double
frees otherwise), but it was added only conditionally for GLib 2.70 or
later. In practice, that means you only get vala compiler issues if you
(impliclty) set `--target-glib=2.70` (or a later version).
To fix this for vala-unit and our own Geary tests, this commit changes
the `ValaUnit.TestCase` class to only allow "stealing" the strong
reference to the `GLib.TestSuite`, rather than somehowing allowing
people to hold a weak reference, and by also making it a protected field
rather than a property.
Since this changes the API of ValaUnit, we also bump the version. In
general though, I hope people aren't using ValaUnit externally, since
these types of API/ABI breaks can happen with Vala libraries.
Link: https://gitlab.gnome.org/GNOME/vala/-/commit/5f0a146f65673379fc84c3cd8e6bca826ffad96f
2025-12-07 10:09:15 +01:00
|
|
|
unowned TestSuite root = TestSuite.get_root();
|
|
|
|
|
root.add_suite((owned) js);
|
2021-02-24 14:58:58 +01:00
|
|
|
|
|
|
|
|
int ret = -1;
|
|
|
|
|
Idle.add(() => {
|
|
|
|
|
ret = Test.run();
|
|
|
|
|
Gtk.main_quit();
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Gtk.main();
|
|
|
|
|
return ret;
|
|
|
|
|
}
|