summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-02-27 08:23:20 +0100
committerEli Schwartz <eschwartz93@gmail.com>2025-02-27 15:25:57 -0500
commitde7d8f9e48b7801659c15f03489d1b5a2fbe7d50 (patch)
treee3aeaa0e96262c83a53c83116c800d23bc0d874d
parent7fd17ab12854ff5339f3309156cd9b705f517fd0 (diff)
downloadmeson-de7d8f9e48b7801659c15f03489d1b5a2fbe7d50.tar.gz
test: fix hang when running tests that need parsing with `--interactive`
When running tests with `--interactive` we don't redirect stdin, stdout or stderr and instead pass them on to the user's console. This redirect causes us to hang in case the test in question needs parsing, like it is the case for TAP output, because we cannot read the process's stdout. Fix this hang by not parsing output when running in interactive mode. Signed-off-by: Patrick Steinhardt <ps@pks.im>
-rw-r--r--mesonbuild/mtest.py2
-rw-r--r--test cases/unit/124 interactive tap/meson.build4
-rwxr-xr-xtest cases/unit/124 interactive tap/script.py5
-rw-r--r--unittests/allplatformstests.py8
4 files changed, 18 insertions, 1 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index 5a5d25758..673f433fd 100644
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -1621,7 +1621,7 @@ class SingleTestRunner:
env=self.runobj.env,
cwd=self.test.workdir)
- if self.runobj.needs_parsing:
+ if self.runobj.needs_parsing and self.console_mode is not ConsoleUser.INTERACTIVE:
parse_coro = self.runobj.parse(harness, p.stdout_lines())
parse_task = asyncio.ensure_future(parse_coro)
else:
diff --git a/test cases/unit/124 interactive tap/meson.build b/test cases/unit/124 interactive tap/meson.build
new file mode 100644
index 000000000..30518db6f
--- /dev/null
+++ b/test cases/unit/124 interactive tap/meson.build
@@ -0,0 +1,4 @@
+project('interactive TAP output')
+
+test_script = find_program('script.py')
+test('main', test_script, protocol: 'tap')
diff --git a/test cases/unit/124 interactive tap/script.py b/test cases/unit/124 interactive tap/script.py
new file mode 100755
index 000000000..873a4ae81
--- /dev/null
+++ b/test cases/unit/124 interactive tap/script.py
@@ -0,0 +1,5 @@
+#!/usr/bin/env python3
+
+print('''1..2
+ok 1
+not ok 2''')
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index 8bbe7c644..57aa6315d 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -5177,3 +5177,11 @@ class AllPlatformTests(BasePlatformTests):
testdir = os.path.join(self.common_test_dir, '1 trivial')
self.init(testdir, extra_args=['-Dc_args=-DSOMETHING'])
self.init(testdir, extra_args=['--wipe'])
+
+ def test_interactive_tap(self):
+ testdir = os.path.join(self.unit_test_dir, '124 interactive tap')
+ self.init(testdir, extra_args=['--wrap-mode=forcefallback'])
+ output = self._run(self.mtest_command + ['--interactive'])
+ self.assertRegex(output, r'Ok:\s*0')
+ self.assertRegex(output, r'Fail:\s*0')
+ self.assertRegex(output, r'Ignored:\s*1')