Skip to content

Commit a8f8f5e

Browse files
committed
tests: split meson test() definitions into individual test scripts
We currently have one pytest invocation (through one meson test()) which runs all of the tests/test_*.py scripts. However, not all of those will be testable in any particular configuration. We may be building without libsystemd, in which case the test_mctpd.py and test_mctpd_endpoint.py tests will not work. So, define individual test() calls for each of the scripts. This also lets us modify the runtime environment (the mctp-only tests don't require dbus-run-session), and meson can parallelise too. Signed-off-by: Jeremy Kerr <[email protected]>
1 parent 04e13ba commit a8f8f5e

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

meson.build

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ mctp_test = executable('test-mctp',
6363
include_directories: include_directories('src'),
6464
)
6565

66-
test_deps = [mctp_test]
67-
6866
executable('mctp-req',
6967
sources: ['src/mctp-req.c'] + util_sources,
7068
)
@@ -99,7 +97,6 @@ if libsystemd.found()
9997
include_directories: include_directories('src'),
10098
dependencies: [libsystemd, toml_dep],
10199
)
102-
test_deps += mctpd_test
103100
endif
104101

105102
tests = get_option('tests')
@@ -140,26 +137,36 @@ if tests
140137
# to allow pytest to print output directly onto the terminal without
141138
# redirecting to a file. We can detect this if stdout is an terminal, and
142139
# disable TAP protocol.
140+
test_dir = join_paths(meson.current_source_dir(), 'tests')
141+
pytest_conf = join_paths(test_dir, 'pytest.ini')
142+
143143
pytest = find_program('pytest')
144-
script = 'if [ ! -t 1 ]; then PFL="--tap"; fi; DBUS_STARTER_BUS_TYPE=user "@0@" $PFL $@'.format(
145-
pytest.full_path()
144+
script = 'if [ ! -t 1 ]; then PFL="--tap"; fi; DBUS_STARTER_BUS_TYPE=user "@0@" $PFL --config-file "@1@" $@'.format(
145+
pytest.full_path(),
146+
pytest_conf,
146147
)
147148
sh = find_program('sh')
148-
dbus_run_session = find_program('dbus-run-session')
149-
150-
test_conf_data = configuration_data()
151-
test_conf_data.set('testpaths',
152-
join_paths(meson.current_source_dir(), 'tests')
153-
)
154-
configure_file(
155-
input: 'tests/pytest.ini.in',
156-
output: 'pytest.ini',
157-
configuration: test_conf_data,
158-
)
159-
160-
test('test-mctpd', dbus_run_session,
161-
depends: [test_deps],
162-
args: [ sh.full_path(), '-c', script, '--' ],
149+
test_args = [ '-c', script, '--' ]
150+
151+
if libsystemd.found()
152+
dbus_run_session = find_program('dbus-run-session')
153+
154+
test('test-mctpd', dbus_run_session,
155+
depends: [mctpd_test],
156+
args: [sh.full_path()] + test_args + [test_dir / 'test_mctpd.py'],
157+
protocol: 'tap',
158+
)
159+
160+
test('test-mctpd-endpoint', dbus_run_session,
161+
depends: [mctpd_test],
162+
args: [sh.full_path()] + test_args + [test_dir / 'test_mctpd_endpoint.py'],
163+
protocol: 'tap',
164+
)
165+
endif
166+
167+
test('test-mctp', sh,
168+
depends: [mctp_test],
169+
args: test_args + [test_dir / 'test_mctp.py'],
163170
protocol: 'tap',
164171
)
165172

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[pytest]
22
trio_mode = true
3-
testpaths = @testpaths@
43
filterwarnings =
54
ignore:.*wait_readable:DeprecationWarning:asyncdbus
65
ignore:.*wait_writable:DeprecationWarning:asyncdbus

0 commit comments

Comments
 (0)