Merge branch 'test-actions-parallel-fix' into 'main'

tests/desktop-app-info: Use unique temporary paths for action files

See merge request GNOME/glib!2885
This commit is contained in:
Philip Withnall 2022-10-12 14:41:27 +00:00
commit 057a9e5773
2 changed files with 22 additions and 7 deletions

View File

@ -5,12 +5,12 @@ Exec=true
[Desktop Action frob]
Name=Frobnicate
Exec=touch frob
Exec=sh -c '[ -d "$G_TEST_TMPDIR" ] && touch "$G_TEST_TMPDIR/frob"'
[Desktop Action tweak]
Name=Tweak
Exec=touch tweak
Exec=sh -c '[ -d "$G_TEST_TMPDIR" ] && touch "$G_TEST_TMPDIR/tweak"'
[Desktop Action twiddle]
Name=Twiddle
Exec=touch twiddle
Exec=sh -c '[ -d "$G_TEST_TMPDIR" ] && touch "$G_TEST_TMPDIR/twiddle"'

View File

@ -551,7 +551,11 @@ test_actions (void)
const char *expected[] = { "frob", "tweak", "twiddle", "broken", NULL };
const gchar * const *actions;
GDesktopAppInfo *appinfo;
const gchar *tmpdir;
gchar *name;
gchar *frob_path;
gchar *tweak_path;
gchar *twiddle_path;
appinfo = g_desktop_app_info_new_from_filename (g_test_get_filename (G_TEST_DIST, "appinfo-test-actions.desktop", NULL));
g_assert_nonnull (appinfo);
@ -576,17 +580,28 @@ test_actions (void)
g_assert_true (g_utf8_validate (name, -1, NULL));
g_free (name);
unlink ("frob"); unlink ("tweak"); unlink ("twiddle");
tmpdir = g_getenv ("G_TEST_TMPDIR");
g_assert_nonnull (tmpdir);
frob_path = g_build_filename (tmpdir, "frob", NULL);
tweak_path = g_build_filename (tmpdir, "tweak", NULL);
twiddle_path = g_build_filename (tmpdir, "twiddle", NULL);
g_assert_false (g_file_test (frob_path, G_FILE_TEST_EXISTS));
g_assert_false (g_file_test (tweak_path, G_FILE_TEST_EXISTS));
g_assert_false (g_file_test (twiddle_path, G_FILE_TEST_EXISTS));
g_desktop_app_info_launch_action (appinfo, "frob", NULL);
wait_for_file ("frob", "tweak", "twiddle");
wait_for_file (frob_path, tweak_path, twiddle_path);
g_desktop_app_info_launch_action (appinfo, "tweak", NULL);
wait_for_file ("tweak", "frob", "twiddle");
wait_for_file (tweak_path, frob_path, twiddle_path);
g_desktop_app_info_launch_action (appinfo, "twiddle", NULL);
wait_for_file ("twiddle", "frob", "tweak");
wait_for_file (twiddle_path, frob_path, tweak_path);
g_free (frob_path);
g_free (tweak_path);
g_free (twiddle_path);
g_object_unref (appinfo);
}