Muex.DependencyAnalyzer (Muex v0.6.1)

View Source

Analyzes test files to determine which tests depend on which modules.

Builds a dependency graph by parsing test files and extracting module references. This allows running only the tests that are affected by a specific mutation.

Summary

Functions

Analyzes test files and builds a dependency map.

Gets test files that depend on a specific module.

Gets test files for a mutation based on the mutated module.

Types

dependency_map()

@type dependency_map() :: %{required(module()) => [Path.t()]}

Functions

analyze(test_paths \\ ["test"])

@spec analyze([Path.t()] | Path.t()) :: dependency_map()

Analyzes test files and builds a dependency map.

Parameters

  • test_paths - List of test directories, globs, or file paths (default: ["test"])

Returns

Map of module atoms to list of test file paths that reference them.

Examples

iex> analyze(["test"])
%{MyModule => ["test/my_module_test.exs"], ...}

get_dependent_tests(module_name, dependency_map)

@spec get_dependent_tests(module(), dependency_map()) :: [Path.t()]

Gets test files that depend on a specific module.

Parameters

  • module_name - The module to find tests for
  • dependency_map - The dependency map from analyze/1

Returns

List of test file paths that depend on the module.

get_tests_for_mutation(mutation, dependency_map, file_to_module)

@spec get_tests_for_mutation(map(), dependency_map(), %{
  required(Path.t()) => module()
}) :: [Path.t()]

Gets test files for a mutation based on the mutated module.

Parameters

  • mutation - The mutation map containing location info
  • dependency_map - The dependency map from analyze/1
  • file_to_module - Map of file paths to module names

Returns

List of test file paths to execute for this mutation.