Skip to content

Commit 945484a

Browse files
committed
meson: add test to run pytest
The python binary that was initially found is used to launch pytest. It turns out to be surprisingly hard to run 'pytest' in test() with the python binary detected using meson's python module. test() does not allow the "program" argument to be a str, which is what python module's .full_path() returns. So let's "find" the program again. This results in one line of noise in meson output, but I don't see a nicer way. 'ninja -C build test' works. 'meson test -C build' is better, because it can be called with '-v' to print details of the test.
1 parent dd251ab commit 945484a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/systemd/meson.build

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@ python.install_sources(
6767
subdir: 'systemd/test',
6868
)
6969

70+
test(
71+
'unit',
72+
find_program(python.full_path()),
73+
args: [
74+
'-m', 'pytest',
75+
'-v',
76+
python_test_dir,
77+
],
78+
env: { 'PYTHONPATH': meson.current_build_dir() },
79+
)
80+
7081
# The 'update-constants' target
7182
include_dir = libsystemd_dep.get_variable(pkgconfig: 'includedir')
7283

0 commit comments

Comments
 (0)