Skip to content

tuna: Argparse refactoring and testing improvements

John Kacur linux-rt-users 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5tuna: Replace bare except clauses with specific exception typestuna-cmd.py+8 -80 replies
2/5tuna: Eliminate side effects from argparse by deferring type conversionstuna-cmd.py+39 -260 replies
3/5tuna: Eliminate global ps and irqs variablestuna-cmd.py+13 -240 replies
4/5tuna: Add .local/ directory to .gitignore.gitignore+1 -00 replies
5/5tuna: Add tests for converter functions and update test READMEtests/README.md tests/test_converters.py+241 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

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

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
Signature · 1 line
2.54.0