summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/options.py16
-rw-r--r--test cases/common/247 deprecated option/test.json30
-rw-r--r--unittests/platformagnostictests.py6
3 files changed, 28 insertions, 24 deletions
diff --git a/mesonbuild/options.py b/mesonbuild/options.py
index cd7d2eb6d..1ef5087a5 100644
--- a/mesonbuild/options.py
+++ b/mesonbuild/options.py
@@ -999,6 +999,10 @@ class OptionStore:
return value.as_posix()
def set_option(self, key: OptionKey, new_value: ElementaryOptionValues, first_invocation: bool = False) -> bool:
+ error_key = key
+ if error_key.subproject == '':
+ error_key = error_key.evolve(subproject=None)
+
if key.name == 'prefix':
assert isinstance(new_value, str), 'for mypy'
new_value = self.sanitize_prefix(new_value)
@@ -1010,26 +1014,26 @@ class OptionStore:
try:
opt = self.get_value_object_for(key)
except KeyError:
- raise MesonException(f'Unknown options: "{key!s}" not found.')
+ raise MesonException(f'Unknown option: "{error_key}".')
if opt.deprecated is True:
- mlog.deprecation(f'Option {key.name!r} is deprecated')
+ mlog.deprecation(f'Option "{error_key}" is deprecated')
elif isinstance(opt.deprecated, list):
for v in opt.listify(new_value):
if v in opt.deprecated:
- mlog.deprecation(f'Option {key.name!r} value {v!r} is deprecated')
+ mlog.deprecation(f'Option "{error_key}" value {v!r} is deprecated')
elif isinstance(opt.deprecated, dict):
def replace(v: str) -> str:
assert isinstance(opt.deprecated, dict) # No, Mypy can not tell this from two lines above
newvalue = opt.deprecated.get(v)
if newvalue is not None:
- mlog.deprecation(f'Option {key.name!r} value {v!r} is replaced by {newvalue!r}')
+ mlog.deprecation(f'Option "{error_key}" value {v!r} is replaced by {newvalue!r}')
return newvalue
return v
valarr = [replace(v) for v in opt.listify(new_value)]
new_value = ','.join(valarr)
elif isinstance(opt.deprecated, str):
- mlog.deprecation(f'Option {key.name!r} is replaced by {opt.deprecated!r}')
+ mlog.deprecation(f'Option "{error_key}" is replaced by {opt.deprecated!r}')
# Change both this aption and the new one pointed to.
dirty = self.set_option(key.evolve(name=opt.deprecated), new_value)
dirty |= opt.set_value(new_value)
@@ -1039,7 +1043,7 @@ class OptionStore:
changed = opt.set_value(new_value)
if opt.readonly and changed and not first_invocation:
- raise MesonException(f'Tried to modify read only option {str(key)!r}')
+ raise MesonException(f'Tried to modify read only option "{error_key}"')
if key.name == 'prefix' and first_invocation and changed:
assert isinstance(old_value, str), 'for mypy'
diff --git a/test cases/common/247 deprecated option/test.json b/test cases/common/247 deprecated option/test.json
index a644b0405..4b9a4750a 100644
--- a/test cases/common/247 deprecated option/test.json
+++ b/test cases/common/247 deprecated option/test.json
@@ -26,77 +26,77 @@
},
"stdout": [
{
- "line": ".*DEPRECATION: Option 'o1' is deprecated",
+ "line": ".*DEPRECATION: Option \"o1\" is deprecated",
"match": "re",
"count": 1
},
{
- "line": ".*DEPRECATION: Option 'o2' value 'a' is deprecated",
+ "line": ".*DEPRECATION: Option \"o2\" value 'a' is deprecated",
"match": "re",
"count": 1
},
{
- "line": ".*DEPRECATION: Option 'o3' value 'a' is replaced by 'c'",
+ "line": ".*DEPRECATION: Option \"o3\" value 'a' is replaced by 'c'",
"match": "re",
"count": 1
},
{
- "line": ".*DEPRECATION: Option 'o4' value 'true' is replaced by 'enabled'",
+ "line": ".*DEPRECATION: Option \"o4\" value 'true' is replaced by 'enabled'",
"match": "re",
"count": 1
},
{
- "line": ".*DEPRECATION: Option 'o5' value 'auto' is replaced by 'false'",
+ "line": ".*DEPRECATION: Option \"o5\" value 'auto' is replaced by 'false'",
"match": "re",
"count": 1
},
{
- "line": ".*DEPRECATION: Option 'p1' is deprecated",
+ "line": ".*DEPRECATION: Option \"p1\" is deprecated",
"match": "re",
"count": 1
},
{
- "line": ".*DEPRECATION: Option 'p2' value 'a' is deprecated",
+ "line": ".*DEPRECATION: Option \"p2\" value 'a' is deprecated",
"match": "re",
"count": 1
},
{
- "line": ".*DEPRECATION: Option 'p3' value 'a' is replaced by 'c'",
+ "line": ".*DEPRECATION: Option \"p3\" value 'a' is replaced by 'c'",
"match": "re",
"count": 1
},
{
- "line": ".*DEPRECATION: Option 'p4' value 'true' is replaced by 'enabled'",
+ "line": ".*DEPRECATION: Option \"p4\" value 'true' is replaced by 'enabled'",
"match": "re",
"count": 1
},
{
- "line": ".*DEPRECATION: Option 'p5' value 'auto' is replaced by 'false'",
+ "line": ".*DEPRECATION: Option \"p5\" value 'auto' is replaced by 'false'",
"match": "re",
"count": 1
},
{
- "line": ".*DEPRECATION: Option 'c1' is deprecated",
+ "line": ".*DEPRECATION: Option \"c1\" is deprecated",
"match": "re",
"count": 1
},
{
- "line": ".*DEPRECATION: Option 'c2' value 'a' is deprecated",
+ "line": ".*DEPRECATION: Option \"c2\" value 'a' is deprecated",
"match": "re",
"count": 1
},
{
- "line": ".*DEPRECATION: Option 'c3' value 'a' is replaced by 'c'",
+ "line": ".*DEPRECATION: Option \"c3\" value 'a' is replaced by 'c'",
"match": "re",
"count": 1
},
{
- "line": ".*DEPRECATION: Option 'c4' value 'true' is replaced by 'enabled'",
+ "line": ".*DEPRECATION: Option \"c4\" value 'true' is replaced by 'enabled'",
"match": "re",
"count": 1
},
{
- "line": ".*DEPRECATION: Option 'c5' value 'auto' is replaced by 'false'",
+ "line": ".*DEPRECATION: Option \"c5\" value 'auto' is replaced by 'false'",
"match": "re",
"count": 1
}
diff --git a/unittests/platformagnostictests.py b/unittests/platformagnostictests.py
index 75071d9da..579de98ef 100644
--- a/unittests/platformagnostictests.py
+++ b/unittests/platformagnostictests.py
@@ -175,7 +175,7 @@ class PlatformAgnosticTests(BasePlatformTests):
with self.subTest('Changing the backend'):
with self.assertRaises(subprocess.CalledProcessError) as cm:
self.setconf('-Dbackend=none')
- self.assertIn("ERROR: Tried to modify read only option 'backend'", cm.exception.stdout)
+ self.assertIn('ERROR: Tried to modify read only option "backend"', cm.exception.stdout)
# Check that the new value was not written in the store.
with self.subTest('option is stored correctly'):
@@ -451,7 +451,7 @@ class PlatformAgnosticTests(BasePlatformTests):
f.write(line)
with self.assertRaises(subprocess.CalledProcessError) as e:
self.setconf('-Dneg_int_opt=0')
- self.assertIn('Unknown options: ":neg_int_opt"', e.exception.stdout)
+ self.assertIn('Unknown option: "neg_int_opt"', e.exception.stdout)
def test_reconfigure_option(self) -> None:
testdir = self.copy_srcdir(os.path.join(self.common_test_dir, '40 options'))
@@ -501,7 +501,7 @@ class PlatformAgnosticTests(BasePlatformTests):
os.unlink(os.path.join(testdir, 'meson_options.txt'))
with self.assertRaises(subprocess.CalledProcessError) as e:
self.setconf('-Dneg_int_opt=0')
- self.assertIn('Unknown options: ":neg_int_opt"', e.exception.stdout)
+ self.assertIn('Unknown option: "neg_int_opt"', e.exception.stdout)
def test_configure_options_file_added(self) -> None:
"""A new project option file should be detected."""