From b74705a3969eaccad6c92f16a54fc0002307e309 Mon Sep 17 00:00:00 2001 From: Khang D Nguyen Date: Mon, 2 Jun 2025 15:30:47 +0700 Subject: [PATCH 1/3] tests: bump pytest-tap to 3.5 pytest-tap 3.5 prints all the captured stdout and stderr into comments of the TAP output: # --- Captured Err --- # test-mctpd: log #1 # test-mctpd: log #2 # test-mctpd: ... This just improves the situation over having no logs at all, or having to rerun with pytest directly to see the log. Signed-off-by: Khang D Nguyen --- tests/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/requirements.txt b/tests/requirements.txt index 86c41ed..9e726f3 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -3,4 +3,4 @@ pyroute2==0.7.10 pytest==8.3.2 pytest-trio==0.8.0 trio==0.26.2 -pytest-tap==3.4 +pytest-tap==3.5 From e7c87ba25a92f751cff4168a7b00f231b481117a Mon Sep 17 00:00:00 2001 From: Khang D Nguyen Date: Mon, 2 Jun 2025 15:30:47 +0700 Subject: [PATCH 2/3] tests: disable TAP in interactive terminal pytest-tap output is great for just summaries, but the log is very much unreadable if tests fail. Currently there is an unresolved issue related to terminalreporter, see [1]. [1] https://github.com/python-tap/pytest-tap/issues/98 This commit adds a way to disable TAP. Newer versions of meson support an --interactive flag, like so: meson test -C obj --interactive This makes the test run directly in the terminal, not redirected to a file. When this happens, i.e stdout is a terminal, we run the test without TAP. Signed-off-by: Khang D Nguyen --- meson.build | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 684bbd8..706e54c 100644 --- a/meson.build +++ b/meson.build @@ -118,8 +118,13 @@ if tests # Invoke pytest via a shell script under `dbus-run-session` so we can # override the sanitation of `DBUS_STARTER_BUS_TYPE`, ensuring `test-mctpd` # connects to the isolated session bus prepared by `dbus-run-session`. + # + # On newer meson versions, we can use meson test -C build --interactive + # to allow pytest to print output directly onto the terminal without + # redirecting to a file. We can detect this if stdout is an terminal, and + # disable TAP protocol. pytest = find_program('pytest') - script = 'export DBUS_STARTER_BUS_TYPE=user ; @0@ --tap'.format(pytest.full_path()) + script = '''export DBUS_STARTER_BUS_TYPE=user; if [ ! -t 1 ]; then PYTEST_FLAGS="--tap"; fi; @0@ $PYTEST_FLAGS'''.format(pytest.full_path()) sh = find_program('sh') dbus_run_session = find_program('dbus-run-session') From fa13c022855d296126cb03bbddb0cb3f6ddc262a Mon Sep 17 00:00:00 2001 From: Khang D Nguyen Date: Mon, 2 Jun 2025 20:33:28 +0700 Subject: [PATCH 3/3] tests: passthrough meson --test-args to pytest Currently, to my knowledge, there is no way to filter tests when running the testsuite through meson. Manually invoking pytest is the only way. This PR allows such CLI invocation to be possible to filter tests containing "recovery": meson test -C obj --test-args="-k recovery" Signed-off-by: Khang D Nguyen --- meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 706e54c..7bc4940 100644 --- a/meson.build +++ b/meson.build @@ -124,7 +124,7 @@ if tests # redirecting to a file. We can detect this if stdout is an terminal, and # disable TAP protocol. pytest = find_program('pytest') - script = '''export DBUS_STARTER_BUS_TYPE=user; if [ ! -t 1 ]; then PYTEST_FLAGS="--tap"; fi; @0@ $PYTEST_FLAGS'''.format(pytest.full_path()) + script = '''export DBUS_STARTER_BUS_TYPE=user; if [ ! -t 1 ]; then PYTEST_FLAGS="--tap"; fi; @0@ $PYTEST_FLAGS $@'''.format(pytest.full_path()) sh = find_program('sh') dbus_run_session = find_program('dbus-run-session') @@ -140,7 +140,7 @@ if tests test('test-mctpd', dbus_run_session, depends: mctpd_test, - args: [ sh.full_path(), '-c', script ], + args: [ sh.full_path(), '-c', script, '--' ], protocol: 'tap', ) endif