aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2018-10-08 10:05:36 -0700
committerJussi Pakkanen <jpakkane@gmail.com>2018-11-11 00:21:47 +0200
commit50b2ef7354b503ae62abd504cdce938c390b358f (patch)
tree5619ee23e1f69db5630bc9055f882fbb19a96c9a /run_unittests.py
parent59774702b2a09eed289a9b9df89b9b716d27f6c1 (diff)
downloadmeson-50b2ef7354b503ae62abd504cdce938c390b358f.zip
meson-50b2ef7354b503ae62abd504cdce938c390b358f.tar.gz
meson-50b2ef7354b503ae62abd504cdce938c390b358f.tar.bz2
Consider 'samu' when looking for ninja command
samu prints a different message when the build is a no-op, so make assertBuildIsNoop consider that as well. Also, if compile_commands.json cannot be found, just skip the test. This seems reasonable since meson just produces a warning if `ninja -t compdb` fails. Finally, only capture stdout in run_meson_command_tests.py, since the backend may print messages the tests don't recognize to stderr. Fixes #3405.
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/run_unittests.py b/run_unittests.py
index d63a961..298e249 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -921,11 +921,11 @@ class BasePlatformTests(unittest.TestCase):
# Misc stuff
self.orig_env = os.environ.copy()
if self.backend is Backend.ninja:
- self.no_rebuild_stdout = 'ninja: no work to do.'
+ self.no_rebuild_stdout = ['ninja: no work to do.', 'samu: nothing to do']
else:
# VS doesn't have a stable output when no changes are done
# XCode backend is untested with unit tests, help welcome!
- self.no_rebuild_stdout = 'UNKNOWN BACKEND {!r}'.format(self.backend.name)
+ self.no_rebuild_stdout = ['UNKNOWN BACKEND {!r}'.format(self.backend.name)]
self.builddirs = []
self.new_builddir()
@@ -1076,8 +1076,11 @@ class BasePlatformTests(unittest.TestCase):
def get_compdb(self):
if self.backend is not Backend.ninja:
raise unittest.SkipTest('Compiler db not available with {} backend'.format(self.backend.name))
- with open(os.path.join(self.builddir, 'compile_commands.json')) as ifile:
- contents = json.load(ifile)
+ try:
+ with open(os.path.join(self.builddir, 'compile_commands.json')) as ifile:
+ contents = json.load(ifile)
+ except FileNotFoundError:
+ raise unittest.SkipTest('Compiler db not found')
# If Ninja is using .rsp files, generate them, read their contents, and
# replace it as the command for all compile commands in the parsed json.
if len(contents) > 0 and contents[0]['command'].endswith('.rsp'):
@@ -1131,7 +1134,7 @@ class BasePlatformTests(unittest.TestCase):
def assertBuildIsNoop(self):
ret = self.build()
if self.backend is Backend.ninja:
- self.assertEqual(ret.split('\n')[-2], self.no_rebuild_stdout)
+ self.assertIn(ret.split('\n')[-2], self.no_rebuild_stdout)
elif self.backend is Backend.vs:
# Ensure that some target said that no rebuild was done
self.assertIn('CustomBuild:\n All outputs are up-to-date.', ret)