mix credence.normalize_tests (credence v0.8.0)

Copy Markdown

Cosmetic cleanup for agent-authored rule tests (tunex docs/10).

mix credence.normalize_tests test/syntax/foo_fix_test.exs [more...]

An agent often writes heredoc fixtures with a trailing line-continuation \ to drop the final newline:

code = """
foo(bar)\
"""

That's valid (value = "foo(bar)" with no trailing "\n") and sometimes load-bearing — but usually gratuitous and confusing. This task removes each such \ ONLY when it can prove the removal is safe: it deletes the \ (which adds the trailing newline back), re-runs that test file, and keeps the change only if the file is still green — otherwise it reverts. A \ that genuinely pins a newline-free value is left untouched, so a green suite can't go red.

Files whose baseline run is already RED are skipped (we can't attribute a failure). Deletes a single character per edit, so all surrounding formatting is preserved.

Summary

Functions

Normalize one file. opts[:run] is a (path -> exit_code) runner (defaults to mix test <path>); injected in tests. Returns {:ok, removed} / {:noop, 0} / {:skip, 0}.

Functions

normalize_file(path, opts \\ [])

Normalize one file. opts[:run] is a (path -> exit_code) runner (defaults to mix test <path>); injected in tests. Returns {:ok, removed} / {:noop, 0} / {:skip, 0}.