Skip to content

feat(dev): run the test suite on parallel workers - #40

Merged
hamidi-dev merged 1 commit into
mainfrom
feature/faster-tests
Oct 30, 2026
Merged

hamidi-dev merged 1 commit into
mainfrom
feature/faster-tests

Conversation

@hamidi-dev

@hamidi-dev hamidi-dev commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

python3 run_tests.py now runs one worker per CPU, taking the suite from 48s to about 8s locally with the same results as a serial run. -j 1 keeps the old in-process behaviour, and coverage run stays in-process automatically.

Running tests out of order exposed a few that depended on each other, so those now set up and restore their own state.

This also fixes a real bug: on a cold cache, opentab doctor wrote to the cache dir despite its "creates nothing" promise.

Tested on macOS with Python 3.9, 3.12, 3.14 and 3.15, including shuffled runs and every test run alone. This PR's CI is the first Linux run.

Summary by CodeRabbit

  • New Features
    • Test runs can now be filtered by name and configured to use a chosen number of workers. Coverage runs and single-test runs execute in one process.
    • Test output now distinguishes skipped tests from passes and reports failures, including when a worker exits unexpectedly.
  • Improvements
    • Diagnostic reports no longer write parsed catalog data to the cache.
  • Documentation
    • Updated test-running guidance to explain worker behavior, coverage, and failure reporting.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Walkthrough

The test runner now supports filtered test selection and configurable in-process or parallel execution. Tests also update fixture setup and cleanup. Pricing catalog parsing gains a read-only cache context, which the doctor report uses.

Changes: Parallel test execution

Layer / File(s) Summary
Runner options and test selection
run_tests.py, AGENTS.md, CONTRIBUTING.md
The runner accepts test-name filters and a worker count. It selects in-process execution for one worker, defaults to one worker under coverage, and documents worker behavior and debugging commands.
Worker execution and result reporting
run_tests.py, tests/test_run_tests.py
Spawned workers receive test names, capture output, and return outcomes. The runner reports worker failures and continues assigning tests. Integration tests cover selection, outcomes, worker exits, and job-count validation.

Test fixture and cleanup updates

Layer / File(s) Summary
Test fixture setup and cleanup
tests/test_notes.py, tests/test_sources.py, tests/test_tui_whatif.py, tests/test_util.py
Tests use a helper to write notes fixtures, set a SQLite timeout, scope curses patches, and remove HERDR_PANE_ID during cleanup.

Read-only pricing catalog cache

Layer / File(s) Summary
Read-only catalog parsing and doctor report
src/opentab/accounting/pricing.py, src/opentab/cli/doctor.py, tests/test_pricing.py, tests/test_doctor.py
read_only_catalogs() disables catalog-cache writes while preserving cache reads, then restores the prior setting. build_report uses the context, and tests cover cache behavior and report setup.

Priority: Not assessed

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant TestRunner as run_tests.main
  participant Orchestrator as run_parallel
  participant Worker
  participant TestCase as run_case
  TestRunner->>Orchestrator: selected test names and worker count
  Orchestrator->>Worker: assign test name
  Worker->>TestCase: execute test
  TestCase-->>Worker: outcome and traceback
  Worker-->>Orchestrator: result and captured output
  Orchestrator-->>TestRunner: report result
Loading

Possibly related PRs

  • hamidi-dev/opentab#37: Adds parsed pricing-catalog caching, which this change supports with a read-only cache context.
  • hamidi-dev/opentab#39: Extends parsed pricing-catalog caching, which this change also modifies.
Merge Risk: Low · up to bbacf

Parallel execution has bounded diagnostic and cleanup gaps, and overlapping read-only contexts can incorrectly enable cache writes. These warrant owner awareness and follow-up, but the evidence does not establish a broad failure of ordinary suite execution.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hamidi-dev
hamidi-dev merged commit 87fdf3c into main Oct 30, 2026
6 of 7 checks passed
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