From 97f8e3ad7ee2e47c6121cfa3f26282c3c51e4547 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 5 Jul 2017 15:32:40 +0100 Subject: [PATCH 3/3] tests: Make tests fail if they try to connect to the real session bus It is too easy for a developer working in an environment that has a session bus to write tests that pass locally, but fail in minimal environments. This is also risky because the tests might do destructive things on the developer's real session bus. We can avoid connecting to the session bus by consistently removing its address from the environment, and replacing it with something that will always fail. Signed-off-by: Simon McVittie --- test/Makefile.am | 2 ++ test/name-test/Makefile.am | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Makefile.am b/test/Makefile.am index 914dd7f2..1f4057ee 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -200,6 +200,7 @@ installable_test_meta_with_config = \ installcheck_tests = installcheck_environment = \ export XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR; \ + export DBUS_SESSION_BUS_ADDRESS=do-not-use-real-session:; \ export DBUS_TEST_DAEMON=$(DESTDIR)$(DBUS_DAEMONDIR)/dbus-daemon$(EXEEXT); \ export DBUS_TEST_DBUS_LAUNCH=$(DESTDIR)$(bindir)/dbus-launch$(EXEEXT); \ export DBUS_TEST_DBUS_MONITOR=$(DESTDIR)$(bindir)/dbus-monitor$(EXEEXT); \ @@ -211,6 +212,7 @@ installcheck_environment = \ AM_TESTS_ENVIRONMENT = \ export XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR; \ export DBUS_FATAL_WARNINGS=1; \ + export DBUS_SESSION_BUS_ADDRESS=do-not-use-real-session:; \ export DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT); \ export DBUS_TEST_DBUS_LAUNCH=@abs_top_builddir@/tools/dbus-launch$(EXEEXT); \ export DBUS_TEST_DBUS_MONITOR=@abs_top_builddir@/tools/dbus-monitor$(EXEEXT); \ diff --git a/test/name-test/Makefile.am b/test/name-test/Makefile.am index 8ec9de89..92227ed8 100644 --- a/test/name-test/Makefile.am +++ b/test/name-test/Makefile.am @@ -28,6 +28,7 @@ TESTS = if DBUS_ENABLE_EMBEDDED_TESTS if DBUS_UNIX AM_TESTS_ENVIRONMENT = \ + export DBUS_SESSION_BUS_ADDRESS=do-not-use-real-session:; \ export DBUS_TOP_BUILDDIR=@abs_top_builddir@; \ export DBUS_TOP_SRCDIR=@abs_top_srcdir@; \ export PATH="@abs_top_builddir@/bus:$$PATH"; \ @@ -35,7 +36,6 @@ AM_TESTS_ENVIRONMENT = \ export DBUS_TEST_DATA=@abs_top_builddir@/test/data; \ export DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT); \ export XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR; \ - unset DBUS_SESSION_BUS_ADDRESS; \ unset DBUS_SESSION_BUS_PID; \ $(NULL) -- 2.13.2