Skip to content

v1.6.0 — Parallel Execution

Choose a tag to compare

@deligoez deligoez released this 08 Feb 16:57
· 87 commits to master since this release

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 4

Or configure in doctest.php:

return [
    'execution' => [
        'parallel' => 4,
    ],
];

Features

  • Fixed-size worker pool — N concurrent proc_open processes with non-blocking I/O
  • CPU auto-detection — --parallel without 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: N in 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 detection
  • WorkerPool — fixed-size process pool with timeout support
  • ParallelExecutor — orchestrates CodeGenerator → WorkerPool → cleanup
  • WorkItem — value object for parallel queue items
  • TempDirectory — run-scoped temp directory management

CLI

doctest --parallel         # auto-detect CPU cores
doctest --parallel <N>     # or -p <N>
doctest --parallel 4 --stop-on-failure

Documentation