Repository navigation
v1.6.0 — Parallel Execution
Parallel Execution
Run code blocks concurrently using multiple worker processes. Significantly speeds up test suites with many independent blocks.
Quick Start
# Auto-detect CPU cores
doctest --parallel
# Specify worker count
doctest --parallel 4Or configure in doctest.php:
return [
'execution' => [
'parallel' => 4,
],
];Features
- Fixed-size worker pool — N concurrent
proc_openprocesses with non-blocking I/O - CPU auto-detection —
--parallelwithout a value detects logical cores (Linux, macOS, Windows) - Deterministic output — results always reported in source order regardless of worker completion
- Stop-on-failure — works with parallel: stops dispatching new blocks, waits for running workers
- Per-block bootstrap — bootstrap profiles resolved per-block and included in each worker's temp file
- Summary output — shows
Parallel: Nin the summary line when running in parallel mode
What Runs in Parallel
| Block Type | Parallel? | Notes |
|---|---|---|
| Normal blocks | Yes | Standard code blocks with assertions |
throws blocks |
Yes | Exception-expecting blocks |
parse_error blocks |
Yes | Parse error-expecting blocks |
ignore blocks |
No | Skipped immediately |
no_run blocks |
No | Syntax check only |
| Grouped blocks | No | Groups run sequentially (shared state) |
New Classes
CpuCoreDetector— cross-platform CPU core detectionWorkerPool— fixed-size process pool with timeout supportParallelExecutor— orchestrates CodeGenerator → WorkerPool → cleanupWorkItem— value object for parallel queue itemsTempDirectory— run-scoped temp directory management
CLI
doctest --parallel # auto-detect CPU cores
doctest --parallel <N> # or -p <N>
doctest --parallel 4 --stop-on-failureDocumentation
- New Parallel Execution documentation page
- Updated Configuration with
execution.paralleloption