[mutter] tests: Move out test client path init into helper function
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] tests: Move out test client path init into helper function
- Date: Tue, 6 Nov 2018 18:07:50 +0000 (UTC)
commit 32f3bb02e12ffd754d049c8823ec7bf8a75a278f
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Mon Jul 16 17:01:13 2018 +0200
tests: Move out test client path init into helper function
Makes the common test init function simpler to read.
src/tests/test-utils.c | 39 ++++++++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/src/tests/test-utils.c b/src/tests/test-utils.c
index 5faaaa781..ceac34e9d 100644
--- a/src/tests/test-utils.c
+++ b/src/tests/test-utils.c
@@ -57,24 +57,41 @@ G_DEFINE_QUARK (test-runner-error-quark, test_runner_error)
static char *test_client_path;
+static void
+ensure_test_client_path (int argc,
+ char **argv)
+{
+ test_client_path = g_test_build_filename (G_TEST_BUILT,
+ "src",
+ "tests",
+ "mutter-test-client",
+ NULL);
+ if (!g_file_test (test_client_path,
+ G_FILE_TEST_EXISTS | G_FILE_TEST_IS_EXECUTABLE))
+ {
+ g_autofree char *basename;
+ g_autofree char *dirname = NULL;
+
+ basename = g_path_get_basename (argv[0]);
+
+ dirname = g_path_get_dirname (argv[0]);
+ test_client_path = g_build_filename (dirname,
+ "mutter-test-client", NULL);
+ }
+
+ if (!g_file_test (test_client_path,
+ G_FILE_TEST_EXISTS | G_FILE_TEST_IS_EXECUTABLE))
+ g_error ("mutter-test-client executable not found");
+}
+
void
test_init (int *argc,
char ***argv)
{
- char *basename = g_path_get_basename (argv[0]);
- char *dirname = g_path_get_dirname (argv[0]);
-
g_test_init (argc, argv, NULL);
g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=");
- if (g_str_has_prefix (basename, "lt-"))
- test_client_path = g_build_filename (dirname,
- "../mutter-test-client", NULL);
- else
- test_client_path = g_build_filename (dirname,
- "mutter-test-client", NULL);
- g_free (basename);
- g_free (dirname);
+ ensure_test_client_path (*argc, *argv);
}
AsyncWaiter *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]