[gnome-desktop/wip/fmuellner/meson: 38/40] tests: Allow to run uninstalled



commit eee3cd55e380728196fd7e7242f0659720bc040e
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Aug 2 12:08:34 2018 +0200

    tests: Allow to run uninstalled
    
    This allows running them through regular `make check`/`ninja test`
    instead of requiring `gnome-desktop-testing-runner`...
    
    https://gitlab.gnome.org/GNOME/gnome-desktop/merge_requests/7

 tests/meson.build         | 11 +++++++++++
 tests/wallclock-reftest.c |  5 ++++-
 2 files changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/tests/meson.build b/tests/meson.build
index b8ceaa6d..df5634b8 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -5,6 +5,12 @@ test_args = [
   '-DINSTALLED_TEST_DIR="@0@"'.format(test_execdir)
 ]
 
+test_env = [
+  'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
+  'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+  'G_ENABLE_DIAGNOSTICS=0'
+]
+
 test_programs = [
   'wall-clock',
  'wallclock-reftest'
@@ -30,6 +36,11 @@ foreach program: test_programs
       output: program + '.test',
     )
   endif
+
+  test(program,
+    exe,
+    env: test_env
+  )
 endforeach
 
 if get_option('installed_tests')
diff --git a/tests/wallclock-reftest.c b/tests/wallclock-reftest.c
index 0aad4ae0..6428ebe4 100644
--- a/tests/wallclock-reftest.c
+++ b/tests/wallclock-reftest.c
@@ -575,7 +575,10 @@ main (int argc, char **argv)
   g_test_init (&argc, &argv, NULL);
   gtk_init (&argc, &argv);
 
-  basedir = INSTALLED_TEST_DIR;
+  basedir = g_getenv ("G_TEST_SRCDIR");
+  if (basedir == NULL)
+    basedir = INSTALLED_TEST_DIR;
+
   file = g_file_new_for_commandline_arg (basedir);
   add_test_for_file (file, NULL);
   g_object_unref (file);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]