Skip to content

Conversation

@jonasbardino
Copy link
Contributor

@jonasbardino jonasbardino commented Oct 20, 2025

Improved unit test coverage of mig/lib/daemon.py to aim for complete coverage. Added a lot of corner case tests to test signal passing and handlers. Some of the tests include fuzzy timing assertions, which may need further tweaking to avoid false positives.

Adds one new function to the tested library to remove already registered signal handlers, but it is only ever used in the unit tests so far.
Slightly tweaks interruptible_sleep corner cases to fail an assertion if called with non-positive nap_secs and to return right away if called with max_sleep less than nap_secs. Both are unused corner cases only used in the test for now but they may or may not be of use to daemons in the future.

@jonasbardino jonasbardino self-assigned this Oct 20, 2025
@jonasbardino jonasbardino added the test-only Improvements or additions solely for better test coverage - without functionality changes label Oct 20, 2025
@jonasbardino jonasbardino marked this pull request as ready for review October 20, 2025 23:28
…on etc.

Add coverage of several previously missing branches and corner cases.
- Direct event helper testing
- Signal handler verification
- Concurrent event handling
- Nap timing accuracy checks
- Multiple reset cycles
- Error cases like invalid arguments
- Various sleep interruption scenarios
…t in unit

tests to increase isolation and be able to test handling when no handlers where
registered.

Added unit test coverage:
 - Immediate sleep exit with max_secs < nap_secs
 - Positional argument handling
 - Negative max_secs handling
 - Zero max_secs handling
 - Unregistered signal safety
 - Consecutive signal handling

Perhaps a stand-alone test for the new unregister_signal_handlers should also
be added.
 - Verify explicit unregistration of signal handlers
 - Test sleep terminating after a condition becomes true
 - Edge case test for equal max/sleep durations
 - Test error handling when break conditions raise exceptions
 - Direct tests of state reset and setting helpers
 - Integration test with real signal delivery
…guration`.

Move used_signal accounting to class-level. Perhaps we want to maintain it on
actual use and add helpers to track active ones eventually.
@jonasbardino jonasbardino force-pushed the add/improved-unit-test-coverage-of-mig-lib-daemon branch from d526fdd to 7b8d825 Compare October 21, 2025 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test-only Improvements or additions solely for better test coverage - without functionality changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants