diff --git a/gio/tests/Makefile.am b/gio/tests/Makefile.am index 15ab66e93..26c2d95b6 100644 --- a/gio/tests/Makefile.am +++ b/gio/tests/Makefile.am @@ -339,10 +339,6 @@ dist_test_data += \ dist_test_data += \ appinfo-test-actions.desktop \ - appinfo-test-gnome.desktop \ - appinfo-test-notgnome.desktop \ - appinfo-test.desktop \ - appinfo-test2.desktop \ file.c \ org.gtk.test.dbusappinfo.desktop \ x-content/image-dcf/DCIM/Camera/20130831_203925.jpg \ @@ -367,6 +363,35 @@ clean-mimeapps: rm -rf xdgdatadir xdgdatahome xdgconfighome endif +appinfo-test-gnome.desktop: appinfo-test-gnome.desktop.in Makefile + $(AM_V_GEN)$(SED) \ + -e 's|[@]installed_tests_dir[@]|$(installed_testdir)|g' \ + $< > $@ +appinfo-test-notgnome.desktop: appinfo-test-notgnome.desktop.in Makefile + $(AM_V_GEN)$(SED) \ + -e 's|[@]installed_tests_dir[@]|$(installed_testdir)|g' \ + $< > $@ +appinfo-test.desktop: appinfo-test.desktop.in Makefile + $(AM_V_GEN)$(SED) \ + -e 's|[@]installed_tests_dir[@]|$(installed_testdir)|g' \ + $< > $@ +appinfo-test2.desktop: appinfo-test2.desktop.in Makefile + $(AM_V_GEN)$(SED) \ + -e 's|[@]installed_tests_dir[@]|$(installed_testdir)|g' \ + $< > $@ + +appinfo_desktop_templates = \ + appinfo-test-gnome.desktop.in \ + appinfo-test-notgnome.desktop.in \ + appinfo-test.desktop.in \ + appinfo-test2.desktop.in \ + $(NULL) +appinfo_desktop_files = $(appinfo_desktop_templates:.in=) + +EXTRA_DIST += $(appinfo_desktop_templates) +CLEANFILES += $(appinfo_desktop_files) +test_data += $(appinfo_desktop_files) + uninstalled_test_programs += gsettings gschema-compile gsettings_DEPENDENCIES = test.mo CLEANFILES += test.mo de/LC_MESSAGES/test.mo keyfile/gsettings.store diff --git a/gio/tests/appinfo-test-gnome.desktop b/gio/tests/appinfo-test-gnome.desktop.in similarity index 64% rename from gio/tests/appinfo-test-gnome.desktop rename to gio/tests/appinfo-test-gnome.desktop.in index 9e3b42848..e32d545f6 100644 --- a/gio/tests/appinfo-test-gnome.desktop +++ b/gio/tests/appinfo-test-gnome.desktop.in @@ -1,6 +1,6 @@ [Desktop Entry] Type=Application Name=appinfo-test -Exec=./appinfo-test --option +Exec=@installed_tests_dir@/appinfo-test --option OnlyShowIn=GNOME;KDE; NotShowIn=ROX; diff --git a/gio/tests/appinfo-test-notgnome.desktop b/gio/tests/appinfo-test-notgnome.desktop.in similarity index 63% rename from gio/tests/appinfo-test-notgnome.desktop rename to gio/tests/appinfo-test-notgnome.desktop.in index 2f7c11d9c..585818216 100644 --- a/gio/tests/appinfo-test-notgnome.desktop +++ b/gio/tests/appinfo-test-notgnome.desktop.in @@ -1,6 +1,6 @@ [Desktop Entry] Type=Application Name=appinfo-test -Exec=./appinfo-test --option +Exec=@installed_tests_dir@/appinfo-test --option OnlyShowIn=KDE; NotShowIn=GNOME; diff --git a/gio/tests/appinfo-test.c b/gio/tests/appinfo-test.c index 86d0e492c..3a91a2f9b 100644 --- a/gio/tests/appinfo-test.c +++ b/gio/tests/appinfo-test.c @@ -14,7 +14,7 @@ main (int argc, char *argv[]) gchar *expected; gint pid_from_env; - expected = g_test_build_filename (G_TEST_DIST, "appinfo-test.desktop", NULL); + expected = g_test_build_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL); g_assert_cmpstr (envvar, ==, expected); g_free (expected); diff --git a/gio/tests/appinfo-test.desktop b/gio/tests/appinfo-test.desktop.in similarity index 83% rename from gio/tests/appinfo-test.desktop rename to gio/tests/appinfo-test.desktop.in index 90e412043..bc292b135 100644 --- a/gio/tests/appinfo-test.desktop +++ b/gio/tests/appinfo-test.desktop.in @@ -7,7 +7,7 @@ X-GNOME-FullName=example X-GNOME-FullName[de]=Beispiel Comment=GAppInfo example Comment[de]=GAppInfo Beispiel -Exec=./appinfo-test --option %U %i --name %c --filename %k %m %% +Exec=@installed_tests_dir@/appinfo-test --option %U %i --name %c --filename %k %m %% Icon=testicon.svg Terminal=true StartupNotify=true diff --git a/gio/tests/appinfo-test2.desktop b/gio/tests/appinfo-test2.desktop.in similarity index 81% rename from gio/tests/appinfo-test2.desktop rename to gio/tests/appinfo-test2.desktop.in index 1f5539375..70780f812 100644 --- a/gio/tests/appinfo-test2.desktop +++ b/gio/tests/appinfo-test2.desktop.in @@ -6,6 +6,6 @@ X-GNOME-FullName=example X-GNOME-FullName[de]=Beispiel Comment=GAppInfo example Comment[de]=GAppInfo Beispiel -Exec=./appinfo-test --option +Exec=@installed_tests_dir@/appinfo-test --option TryExec=does-not-exist Icon=testicon diff --git a/gio/tests/appinfo.c b/gio/tests/appinfo.c index 58bba4e1d..12e5a0a7e 100644 --- a/gio/tests/appinfo.c +++ b/gio/tests/appinfo.c @@ -133,7 +133,7 @@ test_launch_for_app_info (GAppInfo *appinfo) g_assert (g_app_info_launch_uris (appinfo, NULL, NULL, &error)); g_assert_no_error (error); - path = g_test_get_filename (G_TEST_DIST, "appinfo-test.desktop", NULL); + path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL); file = g_file_new_for_path (path); l = NULL; l = g_list_append (l, file); @@ -144,7 +144,7 @@ test_launch_for_app_info (GAppInfo *appinfo) g_object_unref (file); l = NULL; - uri = g_strconcat ("file://", g_test_get_dir (G_TEST_DIST), "/appinfo-test.desktop", NULL); + uri = g_strconcat ("file://", g_test_get_dir (G_TEST_BUILT), "/appinfo-test.desktop", NULL); l = g_list_append (l, uri); l = g_list_append (l, "file:///etc/group#adm"); @@ -161,7 +161,7 @@ test_launch (Fixture *fixture, GAppInfo *appinfo; const gchar *path; - path = g_test_get_filename (G_TEST_DIST, "appinfo-test.desktop", NULL); + path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL); appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path); g_assert (appinfo != NULL); @@ -191,13 +191,16 @@ test_launch_no_app_id (Fixture *fixture, "Keywords=keyword1;test keyword;\n" "Categories=GNOME;GTK;\n"; - const char *exec_line_variants[] = { - "Exec=./appinfo-test --option %U %i --name %c --filename %k %m %%", - "Exec=./appinfo-test --option %u %i --name %c --filename %k %m %%" - }; - + gchar *exec_line_variants[2]; gsize i; + exec_line_variants[0] = g_strdup_printf ( + "Exec=%s/appinfo-test --option %%U %%i --name %%c --filename %%k %%m %%%%", + g_test_get_dir (G_TEST_BUILT)); + exec_line_variants[1] = g_strdup_printf ( + "Exec=%s/appinfo-test --option %%u %%i --name %%c --filename %%k %%m %%%%", + g_test_get_dir (G_TEST_BUILT)); + g_test_bug ("791337"); for (i = 0; i < G_N_ELEMENTS (exec_line_variants); i++) @@ -229,6 +232,9 @@ test_launch_no_app_id (Fixture *fixture, g_object_unref (appinfo); g_key_file_unref (fake_desktop_file); } + + g_free (exec_line_variants[1]); + g_free (exec_line_variants[0]); } static void @@ -242,7 +248,7 @@ test_locale (const char *locale) g_setenv ("LANGUAGE", locale, TRUE); setlocale (LC_ALL, ""); - path = g_test_get_filename (G_TEST_DIST, "appinfo-test.desktop", NULL); + path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL); appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path); if (g_strcmp0 (locale, "C") == 0) @@ -290,7 +296,7 @@ test_basic (Fixture *fixture, GIcon *icon, *icon2; const gchar *path; - path = g_test_get_filename (G_TEST_DIST, "appinfo-test.desktop", NULL); + path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL); appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path); g_assert_cmpstr (g_app_info_get_id (appinfo), ==, "appinfo-test.desktop"); @@ -317,17 +323,17 @@ test_show_in (Fixture *fixture, GAppInfo *appinfo; const gchar *path; - path = g_test_get_filename (G_TEST_DIST, "appinfo-test.desktop", NULL); + path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL); appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path); g_assert (g_app_info_should_show (appinfo)); g_object_unref (appinfo); - path = g_test_get_filename (G_TEST_DIST, "appinfo-test-gnome.desktop", NULL); + path = g_test_get_filename (G_TEST_BUILT, "appinfo-test-gnome.desktop", NULL); appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path); g_assert (g_app_info_should_show (appinfo)); g_object_unref (appinfo); - path = g_test_get_filename (G_TEST_DIST, "appinfo-test-notgnome.desktop", NULL); + path = g_test_get_filename (G_TEST_BUILT, "appinfo-test-notgnome.desktop", NULL); appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path); g_assert (!g_app_info_should_show (appinfo)); g_object_unref (appinfo); @@ -471,7 +477,7 @@ test_tryexec (Fixture *fixture, GAppInfo *appinfo; const gchar *path; - path = g_test_get_filename (G_TEST_DIST, "appinfo-test2.desktop", NULL); + path = g_test_get_filename (G_TEST_BUILT, "appinfo-test2.desktop", NULL); appinfo = (GAppInfo*)g_desktop_app_info_new_from_filename (path); g_assert (appinfo == NULL); @@ -596,7 +602,7 @@ test_startup_wm_class (Fixture *fixture, const char *wm_class; const gchar *path; - path = g_test_get_filename (G_TEST_DIST, "appinfo-test.desktop", NULL); + path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL); appinfo = g_desktop_app_info_new_from_filename (path); wm_class = g_desktop_app_info_get_startup_wm_class (appinfo); @@ -613,7 +619,7 @@ test_supported_types (Fixture *fixture, const char * const *content_types; const gchar *path; - path = g_test_get_filename (G_TEST_DIST, "appinfo-test.desktop", NULL); + path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL); appinfo = G_APP_INFO (g_desktop_app_info_new_from_filename (path)); content_types = g_app_info_get_supported_types (appinfo); @@ -638,7 +644,7 @@ test_from_keyfile (Fixture *fixture, const gchar *name; const gchar *path; - path = g_test_get_filename (G_TEST_DIST, "appinfo-test.desktop", NULL); + path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL); kf = g_key_file_new (); g_key_file_load_from_file (kf, path, G_KEY_FILE_NONE, &error); g_assert_no_error (error); @@ -673,19 +679,11 @@ test_from_keyfile (Fixture *fixture, int main (int argc, char *argv[]) { - const gchar *build_dir; - g_setenv ("XDG_CURRENT_DESKTOP", "GNOME", TRUE); g_test_init (&argc, &argv, NULL); g_test_bug_base ("https://bugzilla.gnome.org/show_bug.cgi?id="); - /* With Meson build we need to change into right directory, so that the - * appinfo-test binary can be found. */ - build_dir = g_getenv ("G_TEST_BUILDDIR"); - if (build_dir) - g_chdir (build_dir); - g_test_add ("/appinfo/basic", Fixture, NULL, setup, test_basic, teardown); g_test_add ("/appinfo/text", Fixture, NULL, setup, test_text, teardown); g_test_add ("/appinfo/launch", Fixture, NULL, setup, test_launch, teardown); diff --git a/gio/tests/desktop-app-info.c b/gio/tests/desktop-app-info.c index 4871d85a5..48317967c 100644 --- a/gio/tests/desktop-app-info.c +++ b/gio/tests/desktop-app-info.c @@ -365,7 +365,7 @@ test_extra_getters (void) g_setenv ("LANGUAGE", "de_DE.UTF8", TRUE); setlocale (LC_ALL, ""); - appinfo = g_desktop_app_info_new_from_filename (g_test_get_filename (G_TEST_DIST, "appinfo-test.desktop", NULL)); + appinfo = g_desktop_app_info_new_from_filename (g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL)); g_assert (appinfo != NULL); g_assert (g_desktop_app_info_has_key (appinfo, "Terminal")); @@ -814,7 +814,7 @@ test_launch_as_manager (void) return; } - path = g_test_get_filename (G_TEST_DIST, "appinfo-test.desktop", NULL); + path = g_test_get_filename (G_TEST_BUILT, "appinfo-test.desktop", NULL); appinfo = g_desktop_app_info_new_from_filename (path); g_assert_nonnull (appinfo); @@ -841,15 +841,8 @@ int main (int argc, char *argv[]) { - const gchar *build_dir; gint result; - /* With Meson build we need to change into right directory, so that the - * appinfo-test binary can be found. */ - build_dir = g_getenv ("G_TEST_BUILDDIR"); - if (build_dir) - g_chdir (build_dir); - g_test_init (&argc, &argv, NULL); basedir = g_get_current_dir (); diff --git a/gio/tests/meson.build b/gio/tests/meson.build index 63e21bdbc..a07ddf807 100644 --- a/gio/tests/meson.build +++ b/gio/tests/meson.build @@ -395,15 +395,35 @@ if host_machine.system() != 'windows' } endif +appinfo_test_desktop_files = [ + 'appinfo-test-gnome.desktop', + 'appinfo-test-notgnome.desktop', + 'appinfo-test.desktop', + 'appinfo-test2.desktop', +] + +cdata = configuration_data() +if installed_tests_enabled + cdata.set('installed_tests_dir', installed_tests_execdir) +else + cdata.set('installed_tests_dir', meson.current_build_dir()) +endif + +foreach appinfo_test_desktop_file : appinfo_test_desktop_files + configure_file( + input: appinfo_test_desktop_file + '.in', + output: appinfo_test_desktop_file, + install_dir: installed_tests_execdir, + install: installed_tests_enabled, + configuration: cdata, + ) +endforeach + if installed_tests_enabled install_data( 'contexts.c', 'g-icon.c', 'appinfo-test-actions.desktop', - 'appinfo-test-gnome.desktop', - 'appinfo-test-notgnome.desktop', - 'appinfo-test.desktop', - 'appinfo-test2.desktop', 'file.c', 'org.gtk.test.dbusappinfo.desktop', install_dir : installed_tests_execdir,