From cbea968971894643764b695c643cf65ff884d391 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 23 Nov 2016 15:58:20 +0100 Subject: tests: Accept fancy quotes in GLib error messages --- src/tests/test.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/tests/test.c b/src/tests/test.c index 9d8b26b..9971379 100644 --- a/src/tests/test.c +++ b/src/tests/test.c @@ -35,6 +35,7 @@ static GMainLoop *loop; static GThread *main_thread; +static char* last_failure_message; /* ---------------------------------------------------------------------------------------------------- */ @@ -58,6 +59,8 @@ on_completed_expect_failure (UDisksJob *object, g_assert (g_thread_self () == main_thread); if (expected_message != NULL) g_assert_cmpstr (message, ==, expected_message); + g_free (last_failure_message); + last_failure_message = g_strdup (message); g_assert (!success); } @@ -94,8 +97,12 @@ test_spawned_job_missing_program (void) UDisksSpawnedJob *job; job = udisks_spawned_job_new ("/path/to/unknown/file", NULL, getuid (), geteuid (), NULL, NULL); - _g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_failure), - (gpointer) "Error spawning command-line `/path/to/unknown/file': Failed to execute child process \"/path/to/unknown/file\" (No such file or directory) (g-exec-error-quark, 8)"); + _g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_failure), NULL); + /* different GLib versions have different quoting style, be liberal */ + g_assert (strstr (last_failure_message, "Error spawning command-line")); + g_assert (strstr (last_failure_message, "Failed to execute child process")); + g_assert (strstr (last_failure_message, "/path/to/unknown/file")); + g_assert (strstr (last_failure_message, "No such file or directory")); g_object_unref (job); } @@ -169,8 +176,12 @@ test_spawned_job_override_signal_handler (void) job = udisks_spawned_job_new ("/path/to/unknown/file", NULL, getuid (), geteuid (), NULL, NULL /* GCancellable */); handler_ran = FALSE; g_signal_connect (job, "spawned-job-completed", G_CALLBACK (on_spawned_job_completed), &handler_ran); - _g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_failure), - (gpointer) "Error spawning command-line `/path/to/unknown/file': Failed to execute child process \"/path/to/unknown/file\" (No such file or directory) (g-exec-error-quark, 8)"); + _g_assert_signal_received (job, "completed", G_CALLBACK (on_completed_expect_failure), NULL); + /* different GLib versions have different quoting style, be liberal */ + g_assert (strstr (last_failure_message, "Error spawning command-line")); + g_assert (strstr (last_failure_message, "Failed to execute child process")); + g_assert (strstr (last_failure_message, "/path/to/unknown/file")); + g_assert (strstr (last_failure_message, "No such file or directory")); g_assert (handler_ran); g_object_unref (job); } -- cgit v1.2.3