avocado-framework / avocado

Avocado is a set of tools and libraries to help with automated testing. One can call it a test framework with benefits. Native tests are written in Python and they follow the unittest pattern, but any executable can serve as a test.
https://avocado-framework.github.io/
Other
345 stars 343 forks source link

Block timeout introduction #6031

Open richtja opened 2 months ago

richtja commented 2 months ago

This commit introduces a new timeout feature, which adds the possibility to set a specific timeout for a block of code with context manager like this:

with self.wait_max(3):
    #code which should take max 3 seconds
    ...

The wait_max method will send SIGALRM if the code doesn't end within 3 seconds. This signal will be caught by avocado-instrumented runner, which will interrupt the test, the same way as with a regular timeout.

Reference: #5994

richtja commented 1 month ago

Hi @mhartmay, this is something you might be interested in, and I would like to see your opinion. Please have a look.