Skip to content

tests: Fix minor race in desktop-app-info terminals test

Philip Withnall requested to merge pwithnall/glib:fix-desktop-app-info into main

The implementation of g_desktop_app_info_launch_uris() will spawn the exec file once for each URI unless the desktop file has a placeholder in its Exec line which supports multiple URIs at once.

The fake terminal doesn’t have such a placeholder, so the fake terminal script is spawned twice in quick succession, once for each URI. Since it was making two separate printf calls (one to print the output to the pipe, and one to terminate it with a newline), it’s possible that two invocations of the script could interleave their printf calls, resulting in pipe input along the lines of URI1 URI2 newline newline rather than URI1 newline URI2 newline.

This would cause the test to fail.

Fix that by making the script atomic by moving the newline into the first printf call.

See: https://gitlab.gnome.org/GNOME/glib/-/jobs/2339109:

\# Fake 'nxterm' terminal created as: /tmp/bin-path-R6GWT1/nxterm
\# 'nxterm' called with arguments: '-e true nxterm-argument /tmp/bin-path-R6GWT1-e true nxterm-argument /tmp/test_desktop-app-info_CO92T1/desktop-app-info/launch-uris-with-terminal/nxterm/.dirs/data'
Bail out! GLib-GIO:ERROR:../gio/tests/desktop-app-info.c:1294:test_launch_uris_with_terminal: assertion failed (g_strv_length (output_args) == 4): (7 == 4)

Signed-off-by: Philip Withnall pwithnall@endlessos.org

Merge request reports