aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2019-04-18 12:19:19 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2019-04-18 19:18:21 +0000
commit2795f942bef680b0f050cc1f1001db26cab68bb9 (patch)
tree26f4ae38eb5e9b4f852f67fb2023259198835c1e /run_unittests.py
parent2e93ed58c30d63da8527ff16375ff9e0642e7533 (diff)
downloadmeson-2795f942bef680b0f050cc1f1001db26cab68bb9.zip
meson-2795f942bef680b0f050cc1f1001db26cab68bb9.tar.gz
meson-2795f942bef680b0f050cc1f1001db26cab68bb9.tar.bz2
interpreter: Check the meson version before parsing options
Also add a test for it so we don't regress this in the future. Closes https://github.com/mesonbuild/meson/issues/5281
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/run_unittests.py b/run_unittests.py
index 941280d..316525d 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -3644,12 +3644,13 @@ class FailureTests(BasePlatformTests):
super().setUp()
self.srcdir = os.path.realpath(tempfile.mkdtemp())
self.mbuild = os.path.join(self.srcdir, 'meson.build')
+ self.moptions = os.path.join(self.srcdir, 'meson_options.txt')
def tearDown(self):
super().tearDown()
windows_proof_rmtree(self.srcdir)
- def assertMesonRaises(self, contents, match, extra_args=None, langs=None, meson_version=None):
+ def assertMesonRaises(self, contents, match, extra_args=None, langs=None, meson_version=None, options=None):
'''
Assert that running meson configure on the specified @contents raises
a error message matching regex @match.
@@ -3664,6 +3665,9 @@ class FailureTests(BasePlatformTests):
for lang in langs:
f.write("add_languages('{}', required : false)\n".format(lang))
f.write(contents)
+ if options is not None:
+ with open(self.moptions, 'w') as f:
+ f.write(options)
# Force tracebacks so we can detect them properly
os.environ['MESON_FORCE_BACKTRACE'] = '1'
with self.assertRaisesRegex(MesonException, match, msg=contents):
@@ -3896,6 +3900,14 @@ class FailureTests(BasePlatformTests):
"sub1.get_variable('naaa')",
"""Subproject "subprojects/not-found-subproject" disabled can't get_variable on it.""")
+ def test_version_checked_before_parsing_options(self):
+ '''
+ https://github.com/mesonbuild/meson/issues/5281
+ '''
+ options = "option('some-option', type: 'foo', value: '')"
+ match = 'Meson version is.*but project requires >=2000'
+ self.assertMesonRaises("", match, meson_version='>=2000', options=options)
+
@unittest.skipUnless(is_windows() or is_cygwin(), "requires Windows (or Windows via Cygwin)")
class WindowsTests(BasePlatformTests):