Skip to content

Commit

Permalink
Fix application of "run/runs" setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Bechberger committed Aug 24, 2020
1 parent 8fc7e14 commit dfe873a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 11 additions & 2 deletions temci/utils/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def _setup(self):
}
logger.setLevel(mapping[log_level])
self._update_doc()
self.apply_override_actions()

def _update_doc(self):
"""
Expand Down Expand Up @@ -353,13 +354,14 @@ def validate(self):
"""
self._validate_settings_dict(self.prefs)

def set(self, key: str, value, validate: bool = True):
def set(self, key: str, value, validate: bool = True, setup: bool = True):
"""
Sets the setting key to the passed new value
:param key: settings key
:param value: new value
:param validate: validate after the setting operation
:param setup: call the setup function
:raises: SettingsError if the setting isn't valid
"""
tmp = copy.deepcopy(self.prefs)
Expand All @@ -370,7 +372,8 @@ def set(self, key: str, value, validate: bool = True):
if not res:
self.prefs = tmp
raise SettingsError(str(res))
self._setup()
if setup:
self._setup()

def __setitem__(self, key: str, value):
"""
Expand Down Expand Up @@ -531,3 +534,9 @@ def obsoleteness_reason(self, key: t.Union[str, t.List[str]]) -> t.Optional[Obso
if path[-1] in tmp_type and isinstance(tmp_type[path[-1]], Obsolete):
return tmp_type[subkey]
return None

def apply_override_actions(self):
""" Applies actions like overriding max_runs with runs """
if self["run/runs"] > -1:
self.set("run/max_runs", self["run/runs"], setup=False)
self.set("run/min_runs", self["run/runs"], setup=False)
5 changes: 5 additions & 0 deletions tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,8 @@ def test_multiline_perf_command():
}
]
}).yaml_contents["run_output.yaml"][0]["data"]


def test_runs_option_broken():
assert len(run_temci("short exec 'exit 0' --min_runs 2 --max_runs 2 --runs 3")
.yaml_contents["run_output.yaml"][0]["data"]["stime"]) == 3

0 comments on commit dfe873a

Please sign in to comment.