Merge branch '2754-sort-locale' into 'main'

tests: Don’t rely on output locale of sort in spawn-test

Closes #2754

See merge request GNOME/glib!2943
This commit is contained in:
Philip Withnall 2022-10-17 16:12:46 +00:00
commit a55c0dc403

View File

@ -31,6 +31,7 @@
#include <fcntl.h>
#include <io.h>
#define pipe(fds) _pipe(fds, 4096, _O_BINARY)
#include <WinError.h>
#endif
#ifdef G_OS_WIN32
@ -97,7 +98,10 @@ test_spawn_basics (void)
&output, &erroutput, NULL, &err);
g_assert_no_error (err);
g_assert_true (result);
g_assert_cmpstr (output, ==, "line 2\nline first\nline last\n");
if (strchr (output, '\r') != NULL)
g_assert_cmpstr (output, ==, "line 2\r\nline first\r\nline last\r\n");
else
g_assert_cmpstr (output, ==, "line 2\nline first\nline last\n");
g_assert_cmpstr (erroutput, ==, "");
g_free (output);
@ -109,8 +113,16 @@ test_spawn_basics (void)
NULL, &erroutput, NULL, &err);
g_assert_no_error (err);
g_assert_true (result);
#ifndef G_OS_WIN32
g_assert_true (g_str_has_prefix (erroutput, "sort: "));
g_assert_nonnull (strstr (erroutput, "No such file or directory"));
g_assert_nonnull (strstr (erroutput, g_strerror (ENOENT)));
#else
{
gchar *file_not_found_message = g_win32_error_message (ERROR_FILE_NOT_FOUND);
g_assert_nonnull (strstr (erroutput, file_not_found_message));
g_free (file_not_found_message);
}
#endif
g_free (erroutput);
erroutput = NULL;