mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 06:56:14 +01:00
d7e368f206
For the reasons given in https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4176#note_2233317, it’s best to not rely on subprocesses when writing tests. Spawning a subprocess can go wrong, getting feedback and assertion data from a subprocess is a pain, and making sure the subprocess is killed properly at the end of the test is hard to get right. For tests where we are trying to mock a D-Bus service, it’s much more reliable to run that service in-process (either in the main thread or in a separate thread). So, do that for the `fake-document-portal` former subprocess in the `dbus-appinfo` test: move it to a worker thread. This speeds the test up, simplifies the build slightly, and should make the test run more reliable. In particular, it provides a pattern for future `fake-*-portal` tests to be built off. This is particularly useful for more complex portals, where data needs to be relayed back from the mock portal service to the unit test to check that the code under test has behaved properly. That’s a pain to do from a subprocess. Delete the `org.freedesktop.portal.Documents.service` file because we no longer need to rely on D-Bus service activation within the test, as we’re setting up the mock service thread explicitly now. Signed-off-by: Philip Withnall <pwithnall@gnome.org>
38 lines
1.4 KiB
C
38 lines
1.4 KiB
C
/*
|
|
* Copyright 2024 GNOME Foundation
|
|
*
|
|
* SPDX-License-Identifier: LGPL-2.1-or-later
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General
|
|
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef __FAKE_DOCUMENT_PORTAL_H__
|
|
#define __FAKE_DOCUMENT_PORTAL_H__
|
|
|
|
#include <glib.h>
|
|
#include <glib-object.h>
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
#define G_TYPE_FAKE_DOCUMENT_PORTAL_THREAD (g_fake_document_portal_thread_get_type ())
|
|
G_DECLARE_FINAL_TYPE (GFakeDocumentPortalThread, g_fake_document_portal_thread, G, FAKE_DOCUMENT_PORTAL_THREAD, GObject)
|
|
|
|
GFakeDocumentPortalThread *g_fake_document_portal_thread_new (const char *address);
|
|
void g_fake_document_portal_thread_run (GFakeDocumentPortalThread *self);
|
|
void g_fake_document_portal_thread_stop (GFakeDocumentPortalThread *self);
|
|
|
|
G_END_DECLS
|
|
|
|
#endif /* __FAKE_DOCUMENT_PORTAL_H__ */
|