diff --git a/meson.build b/meson.build index 4ba4934..2e4c8cb 100644 --- a/meson.build +++ b/meson.build @@ -13,6 +13,8 @@ project( python = import('python').find_installation('python3', pure: false) python_dep = python.dependency() +fs = import('fs') + libsystemd_dep = dependency('libsystemd') add_project_arguments( @@ -26,4 +28,15 @@ update_constants_py = files('update-constants.py') subdir('src/systemd') +test( + 'unit', + find_program(python.full_path()), + args: [ + '-m', 'pytest', + '-v', + python_test_dir, + ], + env: { 'PYTHONPATH': meson.current_build_dir() / 'src' }, +) + alias_target('update-constants', update_constants) diff --git a/src/systemd/meson.build b/src/systemd/meson.build index 8d01cd7..842be36 100644 --- a/src/systemd/meson.build +++ b/src/systemd/meson.build @@ -46,14 +46,19 @@ python.extension_module( ) # Install Python modules -python.install_sources( +py_files = files( '__init__.py', 'journal.py', 'daemon.py', - subdir: 'systemd', ) -# Install test modules +python.install_sources(py_files, subdir: 'systemd') +foreach file: py_files + fs.copyfile(file) +endforeach + +# Test code +python_test_dir = meson.current_source_dir() / 'test' python.install_sources( 'test/test_daemon.py', 'test/test_journal.py', @@ -62,10 +67,11 @@ python.install_sources( subdir: 'systemd/test', ) +# The 'update-constants' target include_dir = libsystemd_dep.get_variable(pkgconfig: 'includedir') update_constants = custom_target( - output: 'update-constants-impl', + output: 'update-constants', command: [ update_constants_py, meson.current_source_dir() / 'id128-constants.h',