Generate test configuration files via build-time sed, not configure
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 26 Jan 2015 18:55:08 +0000 (18:55 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Tue, 3 Feb 2015 16:19:00 +0000 (16:19 +0000)
This means we can generate a version that works when installed,
from the same source files.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810
Reviewed-by: Philip Withnall
configure.ac
test/Makefile.am

index 8bddc95..c7616a9 100644 (file)
@@ -1782,25 +1782,6 @@ doc/dbus-send.1.xml
 doc/dbus-uuidgen.1.xml
 dbus-1.pc
 dbus-1-uninstalled.pc
-test/data/valid-config-files/debug-allow-all.conf
-test/data/valid-config-files/debug-allow-all-sha1.conf
-test/data/valid-config-files/finite-timeout.conf
-test/data/valid-config-files/incoming-limit.conf
-test/data/valid-config-files-system/debug-allow-all-pass.conf
-test/data/valid-config-files-system/debug-allow-all-fail.conf
-test/data/valid-service-files/org.freedesktop.DBus.TestSuite.PrivServer.service
-test/data/valid-service-files/org.freedesktop.DBus.TestSuiteEchoService.service
-test/data/valid-service-files/org.freedesktop.DBus.TestSuiteForkingEchoService.service
-test/data/valid-service-files/org.freedesktop.DBus.TestSuiteSegfaultService.service
-test/data/valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service
-test/data/valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service
-test/data/valid-service-files-system/org.freedesktop.DBus.TestSuiteEchoService.service
-test/data/valid-service-files-system/org.freedesktop.DBus.TestSuiteSegfaultService.service
-test/data/valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service
-test/data/valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service
-test/data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoExec.service
-test/data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoUser.service
-test/data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoService.service
 ])
 AC_OUTPUT
 
index 667ed2c..294291b 100644 (file)
@@ -362,25 +362,79 @@ EXTRA_DIST += $(static_data)
 
 ## copy tests to builddir so that generated tests and static tests
 ## are all in one place.
-all-local:
+all-local: copy-config-local uninstalled-config-local
+       @:
+
+copy-config-local:
        $(AM_V_at)$(MKDIR_P) data/valid-config-files/session.d
-       $(AM_V_at)set -e && \
+       $(AM_V_GEN)set -e; \
        if test $(srcdir) = . || test $(srcdir) -ef .; then \
                echo '-- No need to copy test data as srcdir = builddir'; \
        else \
                for F in $(static_data); do \
-                       $(MKDIR_P) $${F%/*}; \
-                       rm -f $$F; \
-                       cp $(srcdir)/$$F $$F; \
+                       $(MKDIR_P) "$${F%/*}"; \
+                       rm -f "$$F"; \
+                       cp $(srcdir)/"$$F" "$$F"; \
                done; \
        fi
 
+uninstalled-config-local:
+       $(AM_V_GEN)set -e; \
+       for F in $(in_data); do \
+               $(MKDIR_P) "$${F%/*}"; \
+               sed \
+                       -e 's,[@]DBUS_TEST_DATA[@],@abs_builddir@/data,' \
+                       -e 's,[@]DBUS_TEST_EXEC[@],@abs_builddir@,' \
+                       -e 's,[@]EXEEXT[@],$(EXEEXT),' \
+                       -e 's,[@]TEST_LAUNCH_HELPER_BINARY[@],@abs_top_builddir@/bus/dbus-daemon-launch-helper-test$(EXEEXT),' \
+                       -e 's,[@]TEST_LISTEN[@],$(TEST_LISTEN),' \
+                       < $(srcdir)/"$$F" > "$${F%.in}"; \
+       done
+
+installable-config-local:
+if DBUS_ENABLE_INSTALLED_TESTS
+       $(AM_V_GEN)set -e; \
+       for F in $(in_data); do \
+               $(MKDIR_P) "installable/$${F%/*}"; \
+               sed \
+                       -e 's,[@]DBUS_TEST_DATA[@],$(testexecdir)/data,' \
+                       -e 's,[@]DBUS_TEST_EXEC[@],$(testexecdir),' \
+                       -e 's,[@]EXEEXT[@],$(EXEEXT),' \
+                       -e 's,[@]TEST_LAUNCH_HELPER_BINARY[@],/bin/false,' \
+                       -e 's,[@]TEST_LISTEN[@],$(TEST_LISTEN),' \
+                       < $(srcdir)/"$$F" > "installable/$${F%.in}"; \
+       done
+else
+       @:
+endif
+
+
+install-data-local: install-config-local
+       @:
+
+install-config-local: installable-config-local
+if DBUS_ENABLE_INSTALLED_TESTS
+       $(AM_V_gen)set -e; \
+       for F in $(static_data); do \
+               install -m644 "$(srcdir)/$$F" "$(testexecdir)/$$F"; \
+       done
+       for F in $(in_data); do \
+               install -d "$${F%/*}";
+               install -m644 "installable/$${F%.in}" "$(testexecdir)/$${F%.in}"; \
+       done
+else
+       @:
+endif
+
 ## this doesn't clean most copied test data files when srcdir=builddir
 clean-local:
        $(AM_V_at)if test $(srcdir) = . || test $(srcdir) -ef .; then \
                echo '-- No need to clean test data as srcdir = builddir'; \
        else \
                rm -f $(static_data); \
+               for F in $(in_data); do \
+                       rm -f "$${F%.in}"; \
+               done; \
        fi
 
 imported_data = \
@@ -389,7 +443,11 @@ imported_data = \
        $(NULL)
 
 noinst_DATA = $(imported_data)
-CLEANFILES = $(noinst_DATA) XDG_RUNTIME_DIR
+CLEANFILES = \
+       $(noinst_DATA) \
+       XDG_RUNTIME_DIR \
+       installable \
+       $(NULL)
 
 $(imported_data): data/valid-config-files/%.conf: $(top_builddir)/bus/%.conf
        $(AM_V_at)$(MKDIR_P) data/valid-config-files