Skip to content

Conversation

@stringintech
Copy link
Owner

Summary

Refactors handler process management into a separate Handler type with configurable timeouts and automatic recovery, preventing test suite hangs and enabling reliable execution.

Changes

Usage

# Default timeouts (10s per test, 30s total)
./build/runner --handler ./conformance-handler

# Custom per-test timeout
./build/runner --handler ./conformance-handler --handler-timeout 30s

# Custom total timeout
./build/runner --handler ./conformance-handler --timeout 2m

# Both
./build/runner --handler ./conformance-handler --handler-timeout 5s --timeout 1m

Testing

Introduces TestMain-based re-exec pattern where the test binary acts as both runner and mock handler subprocess, enabling unit tests for different handler behaviors without external fixtures.

Currently tests cover:

  • Normal handler operation
  • Timeout detection for unresponsive handlers
  • Crash detection with stderr capture

Extract handler process management into a separate Handler type with:
- Read timeout to prevent hanging on unresponsive handlers
- Shutdown with fallback to force-kill on timeout
- Automatic handler respawn when broken, allowing remaining tests to continue
- Single handler instance reused across test suites
Introduce HandlerConfig struct and refactor NewHandler to support custom args/env. Add TestMain-based re-exec pattern allowing the test binary to serve as both test runner and mock handler subprocess.

This enables unit testing of different handler behaviors (normal, crash, hang, unresponsive) without external fixtures, verifying the runner correctly handles each scenario.
Add --handler-timeout flag to runner binary allowing users to configure max response wait time per test case (default: 10s).

Add TestHandler_Unresponsive to verify timeout behavior when handler becomes unresponsive.
Adds TestHandler_Crash to verify the runner correctly handles handlers that crash while processing requests. The test confirms ErrHandlerClosed is returned and that panic messages from stderr are captured in the error.
Add --timeout flag (default 30s) to limit total test execution time across all test suites, complementing per-test-case --handler-timeout.
@stringintech
Copy link
Owner Author

Rebased and tested new pre-release v0.0.2-alpha.4 in stringintech/go-bitcoinkernel@b0a31cb.

@stringintech stringintech merged commit e340847 into main Dec 2, 2025
4 checks passed
@stringintech stringintech deleted the handler-refactor branch December 2, 2025 19:16
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.

Add timeout support for test execution

2 participants