[PATCH 0/5] tuna: Argparse refactoring and testing improvements

John Kacur <[email protected]> Thu, 11 Jun 2026 16:38:27 -0400
Newsgroups org.kernel.vger.linux-rt-users
Message-ID <[email protected]>
This series refactors the argparse implementation in tuna-cmd.py to eliminate
side effects during argument parsing and remove global variables, making the
code more maintainable and testable.

The main improvements are:

1. Replace bare except clauses with specific exception types for better error
   handling

2. Defer type conversions until after parsing completes, eliminating side
   effects during argument parsing (parse → convert → execute pattern)

3. Remove global variables (ps, irqs, match_requested) and pass them as
   function parameters instead

4. Add comprehensive unit tests (12 tests) for argument converter functions
   using mock objects to avoid requiring procfs access

5. Update test documentation with detailed examples and explanations

All tests pass (18 total) and run without requiring root privileges.

John Kacur (5):
  tuna: Replace bare except clauses with specific exception types
  tuna: Eliminate side effects from argparse by deferring type
    conversions
  tuna: Eliminate global ps and irqs variables
  tuna: Add .local/ directory to .gitignore
  tuna: Add tests for converter functions and update test README

 .gitignore               |   1 +
 tests/README.md          |  85 ++++++++++++++++++++-
 tests/test_converters.py | 160 +++++++++++++++++++++++++++++++++++++++
 tuna-cmd.py              | 114 ++++++++++++++--------------
 4 files changed, 300 insertions(+), 60 deletions(-)
 create mode 100644 tests/test_converters.py

-- 
2.54.0