Debian Codegraph @

testsuite/tests/crate_config/reserved_names/test.py

raw
1 """
2 Test that reserved configuration variable names are rejected
3 """
4
5 import os.path
6
7 from drivers.alr import run_alr, init_local_crate, alr_manifest
8 from drivers.asserts import assert_match
9 from drivers.helpers import content_of
10
11 test_dir = os.getcwd()
12
13 crate_name = "xxx"
14 for name in ["crate_version", "Crate_VERsion", "crate_name", "alire_",
15 "ada_compiler_switches", "c_compiler_switches"]:
16 init_local_crate(name=crate_name)
17
18 with open(alr_manifest(), "at") as manifest:
19 manifest.write("[configuration.variables]\n")
20 manifest.write('%s = {type = "Boolean", default = false}\n' % name)
21
22 p = run_alr("update", complain_on_error=False)
23 assert p.status != 0, "alr should have errored"
24 assert_match(".*\n"
25 "ERROR: Configuration variable name '%s.%s' "
26 "is reserved for Alire internal use\n.*" % (crate_name, name.lower()),
27 p.out)
28
29 os.chdir("..")
30
31 # Create a different crate name for the next iteration
32 crate_name += "x"
33
34 print('SUCCESS')