From ba0694bfb90504fdee107ea4ad22f805df3b8b3f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 29 Jan 2016 00:00:00 +0100 Subject: [PATCH 1/3] .gitignore: ignore tests and their results --- .gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 6512b790..66db326b 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,11 @@ lib/xdg-app-enum-types.c lib/xdg-app-enum-types.h test-libxdg-app XdgApp-1.0.* +/doc/reference/gtkdoc-check.log +/doc/reference/gtkdoc-check.test +/doc/reference/gtkdoc-check.trs +/test-doc-portal +/test-doc-portal.log +/test-doc-portal.trs +/testdb.log +/testdb.trs From 74c652a176946c2760d7c78d1947f5bc0e1fc805 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 29 Jan 2016 00:02:00 +0100 Subject: [PATCH 2/3] test-doc-portal: split out global setup/teardown into functions Signed-off-by: Simon McVittie --- tests/test-doc-portal.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/tests/test-doc-portal.c b/tests/test-doc-portal.c index dbd9c4d5..df4b8ec9 100644 --- a/tests/test-doc-portal.c +++ b/tests/test-doc-portal.c @@ -211,10 +211,9 @@ test_recursive_doc (void) g_assert_cmpstr (id, ==, id3); } -int -main (int argc, char **argv) +static void +global_setup (void) { - int res; gboolean inited; GError *error = NULL; gint exit_status; @@ -251,13 +250,12 @@ main (int argc, char **argv) g_assert_no_error (error); g_assert (inited); g_assert (mountpoint != NULL); +} - g_test_init (&argc, &argv, NULL); - - g_test_add_func ("/db/create_doc", test_create_doc); - g_test_add_func ("/db/recursive_doc", test_recursive_doc); - - res = g_test_run (); +static void +global_teardown (void) +{ + GError *error = NULL; g_free (mountpoint); @@ -277,6 +275,23 @@ main (int argc, char **argv) sleep (1); glnx_shutil_rm_rf_at (-1, outdir, NULL, NULL); +} + +int +main (int argc, char **argv) +{ + int res; + + g_test_init (&argc, &argv, NULL); + + g_test_add_func ("/db/create_doc", test_create_doc); + g_test_add_func ("/db/recursive_doc", test_recursive_doc); + + global_setup (); + + res = g_test_run (); + + global_teardown (); return res; } From aaae0d0b6db23b16ac4f5e455d29cc7b02c8c914 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 28 Jan 2016 12:24:34 +0100 Subject: [PATCH 3/3] test-doc-portal: skip all tests if no FUSE Signed-off-by: Simon McVittie --- tests/test-doc-portal.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test-doc-portal.c b/tests/test-doc-portal.c index df4b8ec9..e37af196 100644 --- a/tests/test-doc-portal.c +++ b/tests/test-doc-portal.c @@ -21,6 +21,7 @@ GTestDBus *dbus; GDBusConnection *session_bus; XdpDbusDocuments *documents; char *mountpoint; +static gboolean have_fuse; static char * make_doc_dir (const char *id, const char *app) @@ -157,6 +158,12 @@ test_create_doc (void) const char *basename = "a-file"; GError *error = NULL; + if (!have_fuse) + { + g_test_skip ("this test requires FUSE"); + return; + } + id = export_new_file (basename, "content", FALSE); assert_doc_has_contents (id, basename, NULL, "content"); @@ -191,6 +198,12 @@ test_recursive_doc (void) g_autofree char *path = NULL; g_autofree char *app_path = NULL; + if (!have_fuse) + { + g_test_skip ("this test requires FUSE"); + return; + } + id = export_new_file (basename, "recursive-content", FALSE); assert_doc_has_contents (id, basename, NULL, "recursive-content"); @@ -215,9 +228,19 @@ static void global_setup (void) { gboolean inited; + g_autofree gchar *fusermount = NULL; GError *error = NULL; gint exit_status; + fusermount = g_find_program_in_path ("fusermount"); + /* cache result so subsequent tests can be marked as skipped */ + have_fuse = (access ("/dev/fuse", W_OK) == 0 && + fusermount != NULL && + g_file_test (fusermount, G_FILE_TEST_IS_EXECUTABLE)); + + if (!have_fuse) + return; + g_mkdtemp (outdir); g_print ("outdir: %s\n", outdir); @@ -257,6 +280,9 @@ global_teardown (void) { GError *error = NULL; + if (!have_fuse) + return; + g_free (mountpoint); g_object_unref (documents);