Muex.Config (Muex v0.6.1)

View Source

Central configuration for Muex mutation testing runs.

Parses command-line arguments into a normalized struct consumed by the pipeline. Supports umbrella apps (--app), explicit test paths (--test-paths), and all existing flags.

Compile-Time Configuration

Custom language adapters and mutators can be registered via Application.compile_env/3 in config/config.exs (or any imported config file). These maps are merged into the built-in adapters/mutators at compile time.

  • :languages - A %{String.t() => module()} map of additional language adapters. Each key is the CLI name passed to --language and the value is a module implementing the Muex.Language behaviour.

    config :muex, languages: %{"lua" => MyApp.Language.Lua}
  • :mutators - A %{String.t() => module()} map of additional mutators. Each key is the CLI name usable in --mutators and the value is a module implementing the Muex.Mutator behaviour.

    config :muex, mutators: %{"string" => MyApp.Mutator.String}

The built-in language adapters ("elixir", "erlang") and mutators ("arithmetic", "comparison", "boolean", "literal", "function_call", "conditional") are always available. Entries in the compile-time maps override built-in entries with the same key.

CLI Options

  • --files / --path - Source directory, file, or glob pattern (default: "lib")
  • --test-paths - Comma-separated list of test directories, files, or glob patterns (default: "test"). Each entry is resolved independently: a directory is expanded to dir/**/*_test.exs, a glob is used as-is, and a regular file is taken literally.
  • --app - Target a single OTP application inside an umbrella project. Sets --files to apps/<app>/lib and --test-paths to apps/<app>/test unless those flags are provided explicitly.
  • --language - Language adapter: elixir or erlang (default: elixir)
  • --mutators - Comma-separated list of mutator names (default: all)
  • --mutator-paths - Comma-separated directories containing custom mutator modules implementing Muex.Mutator behaviour. Files are compiled and loaded at runtime.
  • --concurrency - Number of parallel workers (default: number of schedulers)
  • --timeout - Test timeout in milliseconds (default: 10000)
  • --fail-at - Minimum mutation score percentage to pass (default: 80)
  • --format - Output format: terminal, json, html (default: terminal)
  • --min-score - Minimum file complexity score for inclusion (default: 20)
  • --max-mutations - Cap total mutations tested; 0 = unlimited (default: 0)
  • --no-filter - Disable intelligent file filtering
  • --verbose - Show detailed progress information
  • --optimize / --no-optimize - Enable/disable mutation optimization (default: enabled)
  • --optimize-level - Preset: conservative, balanced, aggressive (default: balanced)
  • --min-complexity - Override minimum complexity for optimizer
  • --max-per-function - Override maximum mutations per function for optimizer

Summary

Functions

Expands a single test path entry into matching file paths.

Expands a list of test path entries into actual file paths on disk.

Parses a list of CLI argument strings into a %Config{}.

Builds a %Config{} from a keyword list (already parsed by OptionParser or assembled programmatically).

Returns optimizer options derived from the config's optimization settings.

Types

t()

@type t() :: %Muex.Config{
  app: String.t() | nil,
  concurrency: pos_integer(),
  fail_at: number(),
  files: [String.t()],
  filter: boolean(),
  format: String.t(),
  language: module(),
  max_mutations: non_neg_integer(),
  max_per_function: pos_integer() | nil,
  min_complexity: non_neg_integer() | nil,
  min_score: non_neg_integer(),
  mutators: [module()],
  optimize: boolean(),
  optimize_level: String.t(),
  project_root: Path.t(),
  test_paths: [String.t()],
  timeout_ms: pos_integer(),
  verbose: boolean()
}

Functions

expand_test_path(path)

@spec expand_test_path(String.t()) :: [Path.t()]

Expands a single test path entry into matching file paths.

Handles directories, glob patterns, regular files, and fallback wildcard.

expand_test_paths(paths)

@spec expand_test_paths([String.t()]) :: [Path.t()]

Expands a list of test path entries into actual file paths on disk.

Each entry is treated as follows:

  • Directory -> expands to dir/**/*_test.exs
  • Glob pattern (contains * or ?) -> expanded via Path.wildcard/1
  • Regular file -> taken literally
  • Other -> attempted as a wildcard pattern

from_args(args)

@spec from_args([String.t()]) :: {:ok, t()} | {:error, String.t()}

Parses a list of CLI argument strings into a %Config{}.

Returns {:ok, config} or {:error, reason}.

from_opts(opts)

@spec from_opts(keyword()) :: {:ok, t()} | {:error, String.t()}

Builds a %Config{} from a keyword list (already parsed by OptionParser or assembled programmatically).

Returns {:ok, config} or {:error, reason}.

optimizer_opts(config)

@spec optimizer_opts(t()) :: keyword()

Returns optimizer options derived from the config's optimization settings.