bus1 / dbus-broker

Linux D-Bus Message Broker
https://github.com/bus1/dbus-broker/wiki
Apache License 2.0
677 stars 79 forks source link

test: allow installing built test executables #351

Closed mrc0mmand closed 5 months ago

mrc0mmand commented 6 months ago

This PR introduces two changes: making the reference tests work without a build dir and, subsequently, allowing both reference and unit tests to be installed along with dbus-broker itself, so they can be later used to verify if the installed dbus-broker behaves as expected.

The first change unifies an already existing behavior, where the path to a dbus-daemon binary can be tweaked via an environment variable - the name of the variable was changed to TEST_DBUS_DAEMON, and a new env variable - TEST_DBUS_BROKER - was introduced that does the same thing, but for the dbus-broker binary (instead of hardcoding the path directly). Both paths now default to /usr/bin/{dbus-daemon,dbus-broker}; when running the tests using meson the path for dbus-broker is overridden to point to the just built binary. This should make the tests behave correctly both when run standalone and during development.

The second change makes both unit and reference tests installable (if requested) under <prefix>/share/dbus-broker. The idea here is to follow-up this change with a change in the dbus-broker spec file to split the tests into a separate RPM (like dbus-broker-tests), which can be then easily consumed by the CI infra introduced in #348. The <prefix>/share/dbus-broker path is more like a proposal than a set thing, as I have no preference here. I went through several test packages in Fedora (like systemd-tests, dbus-tests, firewalld-test, etc.), and the <prefix>/share/... path seems to be the most used one.

Also a note: the changes make a heavy use of the meson's "kwargs" feature, which reduces code duplication quite a lot. This was introduced in meson 0.49.0, but since we already depend on at least 0.60.0, we should be, hopefully, fine.

dvdhrm commented 5 months ago

Thanks a lot! I have minor style nits, but I will fix them post merge.