Skip to content

Commit f654998

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 17016e1 commit f654998

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

meson.build

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,15 @@ update_constants_py = files('update-constants.py')
2828

2929
subdir('src/systemd')
3030

31+
test(
32+
'unit',
33+
find_program(python.full_path()),
34+
args: [
35+
'-m', 'pytest',
36+
'-v',
37+
python_test_dir,
38+
],
39+
env: { 'PYTHONPATH': meson.current_build_dir() / 'src' },
40+
)
41+
3142
alias_target('update-constants', update_constants)

src/systemd/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ foreach file: py_files
5858
endforeach
5959

6060
# Test code
61+
python_test_dir = meson.current_source_dir() / 'test'
6162
python.install_sources(
6263
'test/test_daemon.py',
6364
'test/test_journal.py',

0 commit comments

Comments
 (0)