diff --git a/mesonbuild/interpreter/interpreterobjects.py b/mesonbuild/interpreter/interpreterobjects.py index ccaa1c725..b3dbe55f2 100644 --- a/mesonbuild/interpreter/interpreterobjects.py +++ b/mesonbuild/interpreter/interpreterobjects.py @@ -139,7 +139,8 @@ class FeatureOptionHolder(ObjectHolder[coredata.UserFeatureOption]): assert isinstance(error_message, str) if self.value == 'enabled': prefix = f'Feature {self.held_object.name} cannot be enabled' - prefix = prefix + ': ' if error_message else '' + if error_message: + prefix += ': ' raise InterpreterException(prefix + error_message) return self.as_disabled() diff --git a/test cases/failing/106 feature require.bis/meson.build b/test cases/failing/106 feature require.bis/meson.build new file mode 100644 index 000000000..08c099c85 --- /dev/null +++ b/test cases/failing/106 feature require.bis/meson.build @@ -0,0 +1,2 @@ +project('no fallback', 'c') +foo = get_option('reqfeature').require(false) diff --git a/test cases/failing/106 feature require.bis/meson_options.txt b/test cases/failing/106 feature require.bis/meson_options.txt new file mode 100644 index 000000000..5910a8737 --- /dev/null +++ b/test cases/failing/106 feature require.bis/meson_options.txt @@ -0,0 +1 @@ +option('reqfeature', type : 'feature', value : 'enabled', description : 'A required feature') diff --git a/test cases/failing/106 feature require.bis/test.json b/test cases/failing/106 feature require.bis/test.json new file mode 100644 index 000000000..2583990d8 --- /dev/null +++ b/test cases/failing/106 feature require.bis/test.json @@ -0,0 +1,8 @@ +{ + "stdout": [ + { + "match": "re", + "line": ".*/meson\\.build:2:0: ERROR: Feature reqfeature cannot be enabled" + } + ] +}