Skip to content

Let a project type name its tests' extension - #2142

Merged
bbatsov merged 1 commit into
masterfrom
fix/test-file-extension
Jul 29, 2026
Merged

Let a project type name its tests' extension#2142
bbatsov merged 1 commit into
masterfrom
fix/test-file-extension

Conversation

@bbatsov

@bbatsov bbatsov commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Both directions of the implementation/test toggle took the extension from the
file they started with. So in a mix project, toggling from lib/foo.ex offered
to create test/foo_test.ex - which mix test will not run, ExUnit tests being
scripts. :test-suffix only reaches the part of the name before the extension,
as the reporter found.

:src-extension and :test-extension let a type say otherwise, and default to
the old behaviour when it doesn't - so nothing changes for the languages where a
test carries its implementation's extension, which is most of them. Both
directions are covered, since going back from foo_test.exs needs to know the
implementation is .ex.

The bundled elixir type sets them, so the toggle round-trips
lib/foo.ex <-> test/foo_test.exs. They register and update like every other
type attribute, nil clearing them as usual - there's a spec for that, and for
the prefix form as well as the suffix one.

Fixes #1686

Both directions of the implementation/test toggle took the extension
from the file they started with, so an Elixir module in lib/foo.ex
offered to create test/foo_test.ex - which mix will not run, ExUnit
tests being scripts.

:src-extension and :test-extension say otherwise when a type needs to,
and default to the old behaviour when it doesn't. The bundled elixir
type sets them, so the toggle round-trips lib/foo.ex against
test/foo_test.exs.
@bbatsov
bbatsov merged commit 4cdebd1 into master Jul 29, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Jump to non-existence test from Elixir implementation gets an unwanted filename

1 participant