Skip to content

Fix: test runner UX bugs and improve Butler test isolation#121

Open
kamilansri wants to merge 1 commit intoML4SCI:mainfrom
kamilansri:fix/test-runner-UX-bugs
Open

Fix: test runner UX bugs and improve Butler test isolation#121
kamilansri wants to merge 1 commit intoML4SCI:mainfrom
kamilansri:fix/test-runner-UX-bugs

Conversation

@kamilansri
Copy link

Summary

This PR addresses several usability and robustness issues in the manual test runner (run_tests.py) and improves the isolation of the Butler repository creation tests to prevent environment side effects.

Changes

run_tests.py (Test Runner)

  • Fixed "Continue" Logic: The script no longer prompts the user to "Continue with remaining tests?" after the final test has already completed.
  • Robust Argument Parsing: Added validation for test range arguments. Inputs like 1-, 1-3-5, or non-numeric strings now return friendly error messages instead of crashing with a traceback.
  • Graceful Exit: Added KeyboardInterrupt handling to ensure a clean exit (without tracebacks) when the user presses Ctrl+C.

Butler Creation Test Script

  • Removed Hardcoded Paths: Replaced unsafe hardcoded paths (e.g., /tmp/test_repo) with tempfile.TemporaryDirectory() context managers. This ensures tests run in complete isolation and cleans up artifacts automatically, preventing permission errors or stale data from previous runs.
  • Dependency Safety: Added try/except blocks around ripple and lsst imports to allow the script to fail gracefully or skip specific checks if the environment is not fully configured.
  • Method Safety: Added checks to ensure private methods (like _detect_instrument) exist before attempting to test them, preventing crashes during refactors.

Testing

  1. Run python run_tests.py 1-4 and verify the runner does not ask to continue after the last test.
  2. Run python run_tests.py invalid-input to verify the script handles errors without crashing.
  3. Run the Butler test script multiple times in quick succession to ensure no temporary file collisions occur.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant