unittests: add and use get_meson_log_raw function

This is like get_meson_log but returns the whole contents
not split into individual lines.
pull/10339/head
Marvin Scholz 3 years ago committed by Eli Schwartz
parent 49cd97c434
commit 7cbc15b812
  1. 4
      unittests/baseplatformtests.py
  2. 14
      unittests/linuxliketests.py
  3. 5
      unittests/platformagnostictests.py

@ -322,6 +322,10 @@ class BasePlatformTests(TestCase):
each['command'] = compiler + ' ' + f.read() each['command'] = compiler + ' ' + f.read()
return contents return contents
def get_meson_log_raw(self):
with self._open_meson_log() as f:
return f.read()
def get_meson_log(self): def get_meson_log(self):
with self._open_meson_log() as f: with self._open_meson_log() as f:
return f.readlines() return f.readlines()

@ -345,12 +345,12 @@ class LinuxlikeTests(BasePlatformTests):
testdir = os.path.join(self.framework_test_dir, '4 qt') testdir = os.path.join(self.framework_test_dir, '4 qt')
self.init(testdir, extra_args=['-Dmethod=pkg-config']) self.init(testdir, extra_args=['-Dmethod=pkg-config'])
# Confirm that the dependency was found with pkg-config # Confirm that the dependency was found with pkg-config
mesonlog = self.get_meson_log() mesonlog = self.get_meson_log_raw()
if qt4 == 0: if qt4 == 0:
self.assertRegex('\n'.join(mesonlog), self.assertRegex(mesonlog,
r'Run-time dependency qt4 \(modules: Core\) found: YES 4.* \(pkg-config\)') r'Run-time dependency qt4 \(modules: Core\) found: YES 4.* \(pkg-config\)')
if qt5 == 0: if qt5 == 0:
self.assertRegex('\n'.join(mesonlog), self.assertRegex(mesonlog,
r'Run-time dependency qt5 \(modules: Core\) found: YES 5.* \(pkg-config\)') r'Run-time dependency qt5 \(modules: Core\) found: YES 5.* \(pkg-config\)')
@skip_if_not_base_option('b_sanitize') @skip_if_not_base_option('b_sanitize')
@ -380,8 +380,8 @@ class LinuxlikeTests(BasePlatformTests):
testdir = os.path.join(self.framework_test_dir, '4 qt') testdir = os.path.join(self.framework_test_dir, '4 qt')
self.init(testdir, extra_args=['-Dmethod=qmake']) self.init(testdir, extra_args=['-Dmethod=qmake'])
# Confirm that the dependency was found with qmake # Confirm that the dependency was found with qmake
mesonlog = self.get_meson_log() mesonlog = self.get_meson_log_raw()
self.assertRegex('\n'.join(mesonlog), self.assertRegex(mesonlog,
r'Run-time dependency qt5 \(modules: Core\) found: YES .* \(qmake\)\n') r'Run-time dependency qt5 \(modules: Core\) found: YES .* \(qmake\)\n')
def test_qt6dependency_qmake_detection(self): def test_qt6dependency_qmake_detection(self):
@ -400,8 +400,8 @@ class LinuxlikeTests(BasePlatformTests):
testdir = os.path.join(self.framework_test_dir, '4 qt') testdir = os.path.join(self.framework_test_dir, '4 qt')
self.init(testdir, extra_args=['-Dmethod=qmake']) self.init(testdir, extra_args=['-Dmethod=qmake'])
# Confirm that the dependency was found with qmake # Confirm that the dependency was found with qmake
mesonlog = self.get_meson_log() mesonlog = self.get_meson_log_raw()
self.assertRegex('\n'.join(mesonlog), self.assertRegex(mesonlog,
r'Run-time dependency qt6 \(modules: Core\) found: YES .* \(qmake\)\n') r'Run-time dependency qt6 \(modules: Core\) found: YES .* \(qmake\)\n')
def glob_sofiles_without_privdir(self, g): def glob_sofiles_without_privdir(self, g):

@ -83,9 +83,8 @@ class PlatformAgnosticTests(BasePlatformTests):
self.assertNotIn(log_msg, output) self.assertNotIn(log_msg, output)
# Check if message is written to the meson log # Check if message is written to the meson log
mesonlog = os.path.join(self.builddir, 'meson-logs/meson-log.txt') mesonlog = self.get_meson_log_raw()
with open(mesonlog, mode='r', encoding='utf-8') as file: self.assertIn(log_msg, mesonlog)
self.assertIn(log_msg, file.read())
def test_new_subproject_reconfigure(self): def test_new_subproject_reconfigure(self):
testdir = os.path.join(self.unit_test_dir, '107 new subproject on reconfigure') testdir = os.path.join(self.unit_test_dir, '107 new subproject on reconfigure')

Loading…
Cancel
Save