mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-09 07:18:03 +02:00
cmake: add missing environment variables for running tests
To achieve comparable results with Meson, the test environment should
provide the same set of environment variables when used in the source
code or the test environment.
Resolves: dbus/dbus#541
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
(cherry picked from commit 8a78585514)
This commit is contained in:
parent
1a470c60c4
commit
5c611c9339
2 changed files with 39 additions and 2 deletions
|
|
@ -38,6 +38,34 @@ if((DBUS_ENABLE_MODULAR_TESTS OR DBUS_ENABLE_INTRUSIVE_TESTS) AND CMAKE_CROSSCOM
|
|||
endif()
|
||||
endif()
|
||||
|
||||
#
|
||||
# unit test setup
|
||||
#
|
||||
macro(setup_unit_tests)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(DBUS_PATH_DELIMITER ";")
|
||||
else()
|
||||
set(DBUS_PATH_DELIMITER ":")
|
||||
endif()
|
||||
|
||||
# Tests in bus/config-parser.c rely on these specific values for XDG_*
|
||||
set(DBUS_TEST_XDG_DATA_DIRS "${Z_DRIVE_IF_WINE}${PROJECT_BINARY_DIR}/test/XDG_DATA_DIRS" "${Z_DRIVE_IF_WINE}${PROJECT_BINARY_DIR}/test/XDG_DATA_DIRS2")
|
||||
set(DBUS_TEST_XDG_DATA_HOME "${Z_DRIVE_IF_WINE}${PROJECT_BINARY_DIR}/test/XDG_DATA_HOME")
|
||||
set(DBUS_TEST_XDG_RUNTIME_DIR "${Z_DRIVE_IF_WINE}${PROJECT_BINARY_DIR}/test/XDG_RUNTIME_DIR")
|
||||
list(JOIN DBUS_TEST_XDG_DATA_DIRS "${DBUS_PATH_DELIMITER}" DBUS_TEST_XDG_DATA_DIRS_JOINED)
|
||||
|
||||
# the test environment expects these directories to be present
|
||||
foreach(_dir ${DBUS_TEST_XDG_RUNTIME_DIR})
|
||||
if(NOT EXISTS ${_dir})
|
||||
message(STATUS "creating directory '${_dir}' for test environment")
|
||||
file(MAKE_DIRECTORY ${_dir})
|
||||
if(NOT WIN32)
|
||||
file(CHMOD ${_dir} DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
#
|
||||
# add dbus specific test
|
||||
#
|
||||
|
|
@ -56,17 +84,28 @@ macro(add_unit_test _name _target)
|
|||
COMMAND ${TEST_WRAPPER} ${__ARGS} ${Z_DRIVE_IF_WINE}$<TARGET_FILE:${_target}> --tap
|
||||
WORKING_DIRECTORY ${DBUS_TEST_WORKING_DIR}
|
||||
)
|
||||
|
||||
if(NOT setup_unit_tests_called)
|
||||
setup_unit_tests()
|
||||
set(setup_unit_test_called 1)
|
||||
endif()
|
||||
|
||||
set(_env)
|
||||
list(APPEND _env "DBUS_SESSION_BUS_ADDRESS=")
|
||||
list(APPEND _env "DBUS_FATAL_WARNINGS=1")
|
||||
list(APPEND _env "DBUS_TEST_BUILDDIR=${Z_DRIVE_IF_WINE}${PROJECT_BINARY_DIR}/test")
|
||||
list(APPEND _env "DBUS_TEST_DAEMON=${DBUS_TEST_DAEMON}")
|
||||
list(APPEND _env "DBUS_TEST_DATA=${DBUS_TEST_DATA}")
|
||||
list(APPEND _env "DBUS_TEST_DBUS_LAUNCH=${DBUS_TEST_DBUS_LAUNCH}")
|
||||
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")
|
||||
# used by GLib-based tests to implement g_test_build_filename(), etc.
|
||||
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 "XDG_DATA_DIRS=${DBUS_TEST_XDG_DATA_DIRS_JOINED}")
|
||||
list(APPEND _env "XDG_DATA_HOME=${DBUS_TEST_XDG_DATA_HOME}")
|
||||
list(APPEND _env "XDG_RUNTIME_DIR=${DBUS_TEST_XDG_RUNTIME_DIR}")
|
||||
list(APPEND _env ${__ENV})
|
||||
set_tests_properties(${_name} PROPERTIES ENVIRONMENT "${_env}")
|
||||
endmacro()
|
||||
|
|
|
|||
|
|
@ -149,8 +149,6 @@ if(DBUS_ENABLE_INTRUSIVE_TESTS)
|
|||
|
||||
set(SOURCES bus/main.c bus/common.c bus/common.h)
|
||||
add_test_executable(test-bus "${SOURCES}" dbus-daemon-internal dbus-testutils ${EXPAT_LIBRARIES})
|
||||
# TODO: For full coverage this should be run with some specific
|
||||
# environment variable values: see dbus#541
|
||||
set_target_properties(test-bus PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS})
|
||||
|
||||
if(ENABLE_TRADITIONAL_ACTIVATION)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue