mutare_gettext

Hex.pm Hexdocs CI License

A Mutare extension for Gettext macro expansion and argument routing. It produces no mutations of its own. It configures Mutare's built-in mutators to mutate runtime arguments in a use Gettext module while preserving the literals required to compile the metamutant.

Install

# mix.exs
def deps do
[
{:mutare, "~> 0.4.1", only: [:dev, :test], runtime: false},
{:mutare_gettext, "~> 0.2", only: [:dev, :test], runtime: false}
]
end
# .mutare.exs
[extensions: [Mutare.Gettext]]

What it does

Gettext (>= 0.26) requires two accommodations for a single-compile mutation tool:

  1. use Gettext, backend: MyApp.Gettext registers its backend by mutating the caller module, so Mutare's in-process use expansion raises before recovering the injected import Gettext.Macros — leaving bare gettext/ngettext calls unresolved.
  2. A message id (gettext("Hello")) must be a compile-time literal; splicing a mutation selector there causes a macro expansion error and prevents compilation.

The extension fixes both via Mutare's two extension capability behaviours:

This uses a whole-module :raw baseline plus a per-position override for every arity with a count or bindings argument. The overrides are derived from the Gettext macro families; the test suite cross-checks each one against the Gettext.Macros exports.

Targets Gettext >= 0.26; on older versions the extension has no effect.

Development

mix deps.get
mix test
mix check # format --check-formatted, credo, dialyzer

License

MIT — see LICENSE.