tests/test-client: Add helper to run 'script'
The script is a list of newline separated command lines that are sent to the client one by one as if one would have used e.g. meta_test_client_do(). It doesn't have error handling as it's expected to be used from tests, and handling errors in tests that never expects to handle errors is cumbersome. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2810>
This commit is contained in:
parent
b8d0eb80d7
commit
1282f4668f
@ -353,6 +353,29 @@ meta_test_client_do (MetaTestClient *client,
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
meta_test_client_run (MetaTestClient *client,
|
||||
const char *script)
|
||||
{
|
||||
g_auto (GStrv) lines = NULL;
|
||||
int i;
|
||||
|
||||
lines = g_strsplit (script, "\n", -1);
|
||||
for (i = 0; lines[i]; i++)
|
||||
{
|
||||
g_autoptr (GError) error = NULL;
|
||||
|
||||
if (strlen (lines[i]) > 1)
|
||||
{
|
||||
g_autofree char *line = NULL;
|
||||
|
||||
line = g_strdup_printf ("%s\n", lines[i]);
|
||||
if (!meta_test_client_do_line (client, line, &error))
|
||||
g_error ("Failed to do line '%s': %s", lines[i], error->message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_test_client_wait (MetaTestClient *client,
|
||||
GError **error)
|
||||
|
@ -74,6 +74,10 @@ gboolean meta_test_client_dov (MetaTestClient *client,
|
||||
GError **error,
|
||||
va_list vap);
|
||||
|
||||
META_EXPORT
|
||||
void meta_test_client_run (MetaTestClient *client,
|
||||
const char *script);
|
||||
|
||||
META_EXPORT
|
||||
gboolean meta_test_client_do (MetaTestClient *client,
|
||||
GError **error,
|
||||
|
Loading…
Reference in New Issue
Block a user