aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2021-10-13 10:45:23 -0400
committerXavier Claessens <xclaesse@gmail.com>2021-10-14 14:17:50 -0400
commit8a0d12ec295780977d0e2cb7e2f64f1e3a3e0067 (patch)
treed9e8cff75f657c7282459e18c0bb8408a4ec430e /unittests
parent5e96730d7d9f1f6bebf66d04381bc5ec0f80a1cc (diff)
downloadmeson-8a0d12ec295780977d0e2cb7e2f64f1e3a3e0067.zip
meson-8a0d12ec295780977d0e2cb7e2f64f1e3a3e0067.tar.gz
meson-8a0d12ec295780977d0e2cb7e2f64f1e3a3e0067.tar.bz2
optinterpreter: Fix builtin option names not being reserved anymore
Diffstat (limited to 'unittests')
-rw-r--r--unittests/platformagnostictests.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/unittests/platformagnostictests.py b/unittests/platformagnostictests.py
index b26404d..1c52f63 100644
--- a/unittests/platformagnostictests.py
+++ b/unittests/platformagnostictests.py
@@ -13,11 +13,13 @@
# limitations under the License.
import os
+import tempfile
from unittest import skipIf
from .baseplatformtests import BasePlatformTests
from .helpers import is_ci
from mesonbuild.mesonlib import is_linux
+from mesonbuild.optinterpreter import OptionInterpreter, OptionException
@skipIf(is_ci() and not is_linux(), "Run only on fast platforms")
class PlatformAgnosticTests(BasePlatformTests):
@@ -32,3 +34,35 @@ class PlatformAgnosticTests(BasePlatformTests):
'''
testdir = os.path.join(self.unit_test_dir, '99 relative find program')
self.init(testdir, workdir=testdir)
+
+ def test_invalid_option_names(self):
+ interp = OptionInterpreter('')
+
+ def write_file(code: str):
+ with tempfile.NamedTemporaryFile('w', dir=self.builddir, encoding='utf-8', delete=False) as f:
+ f.write(code)
+ return f.name
+
+ fname = write_file("option('default_library', type: 'string')")
+ self.assertRaisesRegex(OptionException, 'Option name default_library is reserved.',
+ interp.process, fname)
+
+ fname = write_file("option('c_anything', type: 'string')")
+ self.assertRaisesRegex(OptionException, 'Option name c_anything is reserved.',
+ interp.process, fname)
+
+ fname = write_file("option('b_anything', type: 'string')")
+ self.assertRaisesRegex(OptionException, 'Option name b_anything is reserved.',
+ interp.process, fname)
+
+ fname = write_file("option('backend_anything', type: 'string')")
+ self.assertRaisesRegex(OptionException, 'Option name backend_anything is reserved.',
+ interp.process, fname)
+
+ fname = write_file("option('foo.bar', type: 'string')")
+ self.assertRaisesRegex(OptionException, 'Option names can only contain letters, numbers or dashes.',
+ interp.process, fname)
+
+ # platlib is allowed, only python.platlib is reserved.
+ fname = write_file("option('platlib', type: 'string')")
+ interp.process(fname)