diff options
author | Hemmo Nieminen <hemmo.nieminen@iki.fi> | 2022-07-12 12:40:03 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2022-08-07 20:48:42 +0300 |
commit | 952dd7773d79074938572216c8f8e73ce602b92c (patch) | |
tree | 3e5ecc34247676aac90823381a60b1cc80244ff6 /unittests | |
parent | 3fbcff1c2722988d05c5248f7ab54c53001b1ee1 (diff) | |
download | meson-952dd7773d79074938572216c8f8e73ce602b92c.zip meson-952dd7773d79074938572216c8f8e73ce602b92c.tar.gz meson-952dd7773d79074938572216c8f8e73ce602b92c.tar.bz2 |
mtest: unify parsed and non-parsed output handling
Use the same routines to handle output both when parsing the output and
when not. Also fixes broken stderr handling for parsed tests.
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/allplatformstests.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 0ac47e7..224f7ca 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -577,6 +577,68 @@ class AllPlatformTests(BasePlatformTests): out = self._run(self.mtest_command + ['--suite', 'verbose']) self.assertIn('1/1 subtest 1', out) + def test_long_output(self): + testdir = os.path.join(self.common_test_dir, '253 long output') + self.init(testdir) + self.build() + self.run_tests() + + # Ensure lines are found from testlog.txt when not being verbose. + + i = 1 + with open(os.path.join(self.logdir, 'testlog.txt'), encoding='utf-8') as f: + line = f.readline() + while line and i < 100001: + if f'# Iteration {i} to stdout' in line: + i += 1 + line = f.readline() + self.assertEqual(i, 100001) + + i = 1 + while line: + if f'# Iteration {i} to stderr' in line: + i += 1 + line = f.readline() + self.assertEqual(i, 100001) + + # Ensure lines are found from both testlog.txt and console when being verbose. + + out = self._run(self.mtest_command + ['-v']) + i = 1 + with open(os.path.join(self.logdir, 'testlog.txt'), encoding='utf-8') as f: + line = f.readline() + while line and i < 100001: + if f'# Iteration {i} to stdout' in line: + i += 1 + line = f.readline() + self.assertEqual(i, 100001) + + i = 1 + while line: + if f'# Iteration {i} to stderr' in line: + i += 1 + line = f.readline() + self.assertEqual(i, 100001) + + lines = out.split('\n') + line_number = 0 + i = 1 + while line_number < len(lines) and i < 100001: + print('---> %s' % lines[line_number]) + if f'# Iteration {i} to stdout' in lines[line_number]: + i += 1 + line_number += 1 + self.assertEqual(i, 100001) + + line_number = 0 + i = 1 + while line_number < len(lines): + if f'# Iteration {i} to stderr' in lines[line_number]: + i += 1 + line_number += 1 + self.assertEqual(i, 100001) + + def test_testsetups(self): if not shutil.which('valgrind'): raise SkipTest('Valgrind not installed.') |