]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
test: Export G_TEST_BUILDDIR, G_TEST_SRCDIR
authorSimon McVittie <smcv@collabora.com>
Mon, 12 Sep 2022 12:24:28 +0000 (13:24 +0100)
committerSimon McVittie <smcv@collabora.com>
Wed, 5 Oct 2022 09:24:24 +0000 (10:24 +0100)
These environment variables are used by GLib's g_test_build_filename()
and related convenience functions, which make it easier for unit tests
to find data files in a way that works for both build-time tests and
"as-installed" tests. During "as-installed" testing, both variables
will normally be unset, and GLib uses the directory containing the
executable. In most cases that results in the right thing happening, and
this will also be true for dbus, since we install the test executables
in ${libexecdir}/installed-tests, helper executables in the same place,
and test data in ${libexecdir}/installed-tests/data.

Signed-off-by: Simon McVittie <smcv@collabora.com>
cmake/modules/Macros.cmake
test/Makefile.am
test/meson.build

index d4c26460decfb2753b7eca849e0c073aaf7a5520..044e2a70dd3e8e8707e7e1a38283ed4dad9ccb78 100644 (file)
@@ -65,6 +65,8 @@ macro(add_unit_test _name _target)
     list(APPEND _env "DBUS_TEST_EXEC=${DBUS_TEST_EXEC}")
     list(APPEND _env "DBUS_TEST_HOMEDIR=${DBUS_TEST_HOMEDIR}")
     list(APPEND _env "DBUS_TEST_UNINSTALLED=1")
+    list(APPEND _env "G_TEST_BUILDDIR=${Z_DRIVE_IF_WINE}${PROJECT_BINARY_DIR}/test")
+    list(APPEND _env "G_TEST_SRCDIR=${Z_DRIVE_IF_WINE}${PROJECT_SOURCE_DIR}/test")
     list(APPEND _env ${__ENV})
     set_tests_properties(${_name} PROPERTIES ENVIRONMENT "${_env}")
 endmacro()
index 116422119d227814a70b6eb02c365f7bf8a29c39..659aead3774caa42aa3ae51041dceb2c70687f9b 100644 (file)
@@ -439,6 +439,8 @@ AM_TESTS_ENVIRONMENT = \
        export DBUS_TEST_EXEC=@abs_top_builddir@/test; \
        export DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus; \
        export DBUS_TEST_UNINSTALLED=1; \
+       export G_TEST_BUILDDIR=@abs_builddir@; \
+       export G_TEST_SRCDIR=@abs_srcdir@; \
        export HOME=@abs_top_builddir@/dbus; \
        $(NULL)
 
index 6de67035b69392fe329521d57d5c87289532ab81..2a3c346d12e6d95c4b0814f747e25bc208bc0ac9 100644 (file)
@@ -43,12 +43,14 @@ test_env = environment()
 
 test_env.set('DBUS_TOP_SRCDIR',     meson.project_source_root())
 test_env.set('DBUS_TEST_SRCDIR',    meson.current_source_dir())
+test_env.set('G_TEST_SRCDIR',       meson.current_source_dir())
 
 test_env.set('DBUS_TOP_BUILDDIR',   meson.project_build_root())
 test_env.set('DBUS_TEST_HOMEDIR',   meson.project_build_root() / 'dbus')
 test_env.set('HOME',                meson.project_build_root() / 'dbus')
 # Tests in bus/config-parser.c rely on this specific value
 test_env.set('DBUS_TEST_BUILDDIR',  meson.current_build_dir())
+test_env.set('G_TEST_BUILDDIR',     meson.current_build_dir())
 test_env.set('DBUS_TEST_EXEC',      meson.current_build_dir())
 test_env.set('DBUS_TEST_DATA',      meson.current_build_dir() / 'data')