Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: twister: Elevate Status Error #77080

Conversation

LukaszMrugala
Copy link
Collaborator

Status errors previously logged an error, but didn't fail the running test.
This commit changes that and introduces a new StatusError to use there.
Additionally, one test is modified so it follows proper status form.

@LukaszMrugala LukaszMrugala added DNM This PR should not be merged (Do Not Merge) and removed DNM This PR should not be merged (Do Not Merge) labels Aug 14, 2024
@LukaszMrugala LukaszMrugala marked this pull request as ready for review August 14, 2024 14:46
logger.error(f'Harness assigned status "{value}"'
f' without an equivalent in TwisterStatus.'
f' Assignment was ignored.')
error_msg = f'Harness assigned status "{value}"' \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if to implement StatusError more like ConfigurationError:

  1. with parameters (where/what) was failed instead of long text message.
  2. with the exception handler in 'runner.py' and logging there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with 1..

What would be the correct handling on the runner.py level - setting the status to ERROR, I presume?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong status assignment is Twister internal problem, it should stop on it, isn't it ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On one hand yes, it is a Twister problem, but it is, at least in theory, contained within one instance. So I think ERRORing the instance and continuing is more appropriate. In the end, ERROR is made for tests failed for reasons outside of the tests' scope (e.g. Build errors).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it is not reliable and an extra complexity to continue execution in this case when there is some logic issue at Twister itself.

scripts/pylib/twister/twisterlib/harness.py Outdated Show resolved Hide resolved
@@ -128,7 +128,7 @@ def test_handler_final_handle_actions(mocked_instance):
handler.suite_name_check = True

harness = twisterlib.harness.Test()
harness.status = mock.Mock()
harness.status = 'NONE'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please also test it for harness.status = None

@LukaszMrugala LukaszMrugala force-pushed the lmrugalx_status_error_enchancement branch from 5669380 to f27d671 Compare August 29, 2024 12:58
@LukaszMrugala LukaszMrugala added the DNM This PR should not be merged (Do Not Merge) label Aug 29, 2024
@LukaszMrugala LukaszMrugala force-pushed the lmrugalx_status_error_enchancement branch from f27d671 to 5e64ef1 Compare August 29, 2024 13:18
@LukaszMrugala LukaszMrugala removed the DNM This PR should not be merged (Do Not Merge) label Aug 29, 2024
hakehuang
hakehuang previously approved these changes Aug 30, 2024
@LukaszMrugala LukaszMrugala force-pushed the lmrugalx_status_error_enchancement branch 3 times, most recently from 574fe41 to 30b9cb0 Compare August 30, 2024 09:05
@LukaszMrugala
Copy link
Collaborator Author

Changes in the rebase, for ease of re-review:

  • Text of the Exception changed a bit (dot added, Exception class name removed from the message)
  • StatusValueError changed to StatusAttributeError (docs indicate AttributeError is appropriate when assignment to attribute fails)
  • Added a test for the exception in test_errors.py
  • Merged two commits

Status errors previously logged an error, but didn't fail the running test.
This commit changes that
 and introduces a new StatusAttributeError to use there.

One test is modified so it follows proper status form.
One test for the new error has been added.

Status errors now will properly mark the Instance as ERROR
and not run TestCases as SKIP.
This necessitated some code layout changes in runner.py

Signed-off-by: Lukasz Mrugala <[email protected]>
@LukaszMrugala LukaszMrugala force-pushed the lmrugalx_status_error_enchancement branch from 30b9cb0 to bd0e9e3 Compare August 30, 2024 12:10
@LukaszMrugala
Copy link
Collaborator Author

This PR's tests should be rerun before merging if #77168 is merged before it.

@carlescufi carlescufi merged commit 345eb8e into zephyrproject-rtos:main Sep 9, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants