Skip to content

Commit

Permalink
Fix unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed Aug 5, 2024
1 parent 72ef192 commit b3ca516
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion mesonbuild/coredata.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ def update_project_options(self, project_options: 'MutableKeyedOptionDictType',
fatal=False)

# Find any extranious keys for this project and remove them
for key in self.optstore.keys() - project_options.keys():
potential_removed_keys = self.optstore.keys() - project_options.keys()
for key in potential_removed_keys:
if self.optstore.is_project_option(key) and key.subproject == subproject:
self.optstore.remove(key)

Expand Down
11 changes: 9 additions & 2 deletions mesonbuild/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ def evolve(self,

def as_root(self) -> 'OptionKey':
"""Convenience method for key.evolve(subproject='')."""
if self.subproject is None or self.subproject == '':
return self
return self.evolve(subproject='')

def as_build(self) -> 'OptionKey':
Expand Down Expand Up @@ -855,7 +857,7 @@ def set_value(self, key: T.Union[OptionKey, str], new_value: 'T.Any') -> bool:
prefix = self.get_value_for('prefix')
new_value = self.sanitize_dir_option_value(prefix, key, new_value)
if key not in self.options:
raise MesonException(f'Internal error, tried to access non-existing option {key.name}.')
raise MesonException(f'Unknown options: "{key.name}" not found.')
valobj = self.options[key]
changed = valobj.set_value(new_value)
if valobj.readonly and changed:
Expand Down Expand Up @@ -924,6 +926,11 @@ def get_option_from_meson_file(self, key: OptionKey):

def remove(self, key):
del self.options[key]
try:
self.project_options.remove(key)
except KeyError:
pass


def __contains__(self, key):
key = self.ensure_and_validate_key(key)
Expand Down Expand Up @@ -1111,7 +1118,7 @@ def set_from_top_level_project_call(self, project_default_options, cmd_line_opti
if key.subproject is None:
projectkey = key.evolve(subproject='')
if key in self.options:
self.options[key].set_value(valstr)
self.set_value(key, valstr)
elif projectkey in self.options:
self.options[projectkey].set_value(valstr)
else:
Expand Down
2 changes: 1 addition & 1 deletion unittests/platformagnostictests.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def write_file(code: str):

def test_option_validation(self):
"""Test cases that are not catch by the optinterpreter itself."""
store = OptionStore()
store = OptionStore(False)
interp = OptionInterpreter(store, '')

def write_file(code: str):
Expand Down

0 comments on commit b3ca516

Please sign in to comment.