Muex.WorkerPool (Muex v0.6.1)

View Source

Manages a pool of workers for parallel mutation testing across all files.

Uses a global queue of mutations with per-file locking to maximize cross-file parallelism while preventing concurrent modifications to the same source file. Each worker operates in an isolated sandbox directory so that parallel mix test invocations don't see each other's mutations.

Scheduling strategy

When a worker slot becomes available, the pool picks the next mutation from any file that is not currently locked. This means mutations targeting different files run in true parallel, while mutations targeting the same file are serialized.

Summary

Functions

Returns a specification to start this module under a supervisor.

Restores any source files left in a mutated state from a previous interrupted run. Checks for .backup files and replaces the originals.

Starts the worker pool.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

restore_backups(paths)

Restores any source files left in a mutated state from a previous interrupted run. Checks for .backup files and replaces the originals.

run_mutations(pool, mutations, file_entries, language_adapter, dependency_map, file_to_module, opts \\ [])

@spec run_mutations(
  pid(),
  [map()],
  %{required(Path.t()) => map()},
  module(),
  map(),
  map(),
  keyword()
) :: [map()]

Runs all mutations through the worker pool.

Accepts the full set of mutations across all files. Mutations targeting different files run in parallel (up to max_workers); mutations targeting the same file are serialized automatically.

Parameters

  • pool - The worker pool PID
  • mutations - List of all mutations to test (across all files)
  • file_entries - Map of file paths to file entry maps
  • language_adapter - The language adapter module
  • dependency_map - Map of modules to test files
  • file_to_module - Map of file paths to module names
  • opts - Options including :timeout_ms, :test_paths, :verbose

Returns

List of mutation results.

start_link(opts \\ [])

Starts the worker pool.

Options

  • :max_workers - Maximum concurrent workers (default: 4)