tests/test-runner: Log each command before running

With verbose mode test runner will log every command before it executes
it. Hopefully this will help in some cases when tests fail in CI with a
timeout.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2893>
This commit is contained in:
Jonas Ådahl 2023-03-04 18:31:36 +01:00
parent e49e9ed59e
commit 875922fbe3

View File

@ -494,11 +494,18 @@ str_to_bool (const char *str,
} }
static gboolean static gboolean
test_case_do (TestCase *test, test_case_do (TestCase *test,
int argc, const char *filename,
char **argv, int line_no,
GError **error) int argc,
char **argv,
GError **error)
{ {
g_autofree char *command = NULL;
command = g_strjoinv (" ", argv);
g_debug ("%s:%d: '%s'", filename, line_no, command);
if (strcmp (argv[0], "new_client") == 0) if (strcmp (argv[0], "new_client") == 0)
{ {
MetaWindowClientType type; MetaWindowClientType type;
@ -1365,6 +1372,7 @@ run_test (MetaContext *context,
int index) int index)
{ {
TestCase *test = test_case_new (context); TestCase *test = test_case_new (context);
g_autofree char *file_basename = NULL;
GError *error = NULL; GError *error = NULL;
GFile *file = g_file_new_for_path (filename); GFile *file = g_file_new_for_path (filename);
@ -1379,6 +1387,8 @@ run_test (MetaContext *context,
in = g_data_input_stream_new (G_INPUT_STREAM (in_raw)); in = g_data_input_stream_new (G_INPUT_STREAM (in_raw));
g_object_unref (in_raw); g_object_unref (in_raw);
file_basename = g_path_get_basename (filename);
int line_no = 0; int line_no = 0;
while (error == NULL) while (error == NULL)
{ {
@ -1401,7 +1411,7 @@ run_test (MetaContext *context,
goto next; goto next;
} }
test_case_do (test, argc, argv, &error); test_case_do (test, file_basename, line_no, argc, argv, &error);
next: next:
if (error) if (error)