diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-02-03 11:38:11 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-02-03 13:38:06 +0100 |
commit | 43567dd386bfa4d59c146056e7636b49455b6b1b (patch) | |
tree | 9c67616f7353a95a775b194e59b1b4751353bb77 | |
parent | validation: Improve no states error message (diff) | |
download | rtems-central-43567dd386bfa4d59c146056e7636b49455b6b1b.tar.bz2 |
validation: Improve non-existant state error msg
-rw-r--r-- | rtemsspec/tests/test_validation.py | 9 | ||||
-rw-r--r-- | rtemsspec/validation.py | 20 |
2 files changed, 22 insertions, 7 deletions
diff --git a/rtemsspec/tests/test_validation.py b/rtemsspec/tests/test_validation.py index d0c74e18..40794f07 100644 --- a/rtemsspec/tests/test_validation.py +++ b/rtemsspec/tests/test_validation.py @@ -2089,3 +2089,12 @@ def test_validation_invalid_actions(): match = "pre-condition 'A' of spec:/a has no states" with pytest.raises(ValueError, match=match): generate(validation_config, item_cache) + action_data["pre-conditions"][0]["states"] = [{ + "name": "A0", + "test-code": None, + "text": None + }] + match = ("transition map entry 0 of spec:/a refers to non-existent " + "post-condition state 'X0'") + with pytest.raises(ValueError, match=match): + generate(validation_config, item_cache) diff --git a/rtemsspec/validation.py b/rtemsspec/validation.py index fda72b80..0549705e 100644 --- a/rtemsspec/validation.py +++ b/rtemsspec/validation.py @@ -537,14 +537,20 @@ class _ActionRequirementTestItem(_TestItem): transition_count *= state_count transition_map = [list() for _ in range(transition_count) ] # type: _TransitionMap - for transition in self["transition-map"]: + for trans_index, transition in enumerate(self["transition-map"]): if isinstance(transition["post-conditions"], dict): - info = ["0"] - post_cond = tuple( - self._post_state_to_index[index][ - transition["post-conditions"][ - self._post_index_to_name[index]]] - for index in range(self._post_condition_count)) + try: + info = ["0"] + post_cond = tuple( + self._post_state_to_index[index][ + transition["post-conditions"][ + self._post_index_to_name[index]]] + for index in range(self._post_condition_count)) + except KeyError as err: + msg = (f"transition map entry {trans_index} of " + f"{self.item.spec} refers to non-existent " + f"post-condition state {err}") + raise ValueError(msg) from err else: info = ["1"] post_cond = tuple( |