|
|
|
@ -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) |
|
|
|
|