Skip to content

Commit b2bf886

Browse files
committed
Improve docs for test patterns
1 parent d703e78 commit b2bf886

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

lib/mix/lib/mix/tasks/test.ex

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -239,29 +239,29 @@ defmodule Mix.Tasks.Test do
239239
`["test"]` if the `test` directory exists, otherwise, it defaults to `[]`.
240240
It is expected that all test paths contain a `test_helper.exs` file
241241
242-
* `:test_pattern` - a pattern to find potential test files.
243-
Defaults to `"*.{ex,exs}"`.
242+
* `:test_pattern` - a pattern to find potential test files. Defaults to `"*.{ex,exs}"`.
244243
245-
In Elixir versions earlier than 1.19.0, this option defaulted to `*_test.exs`,
246-
but to allow better warnings for misnamed test files, it since matches any
247-
Elixir file and expects those to be filtered by `:test_load_filters` and
248-
`:test_ignore_filters`.
244+
Once files are found, they are filtered in two ways:
245+
246+
* Files that match `:test_load_filters` are loaded
247+
* Files that match `:test_ignore_filters` are ignored
248+
* All other files emit a warning
249+
250+
In Elixir versions earlier than 1.19.0, this option defaulted to `*_test.exs`.
249251
250252
* `:test_load_filters` - a list of files, regular expressions or one-arity
251253
functions to restrict which files matched by the `:test_pattern` are loaded.
252254
Defaults to `[&String.ends_with?(&1, "_test.exs")]`. Paths are relative to
253255
the project root and separated by `/`, even on Windows.
254256
255257
* `:test_ignore_filters` - a list of files, regular expressions or one-arity
256-
functions to restrict which files matched by the `:test_pattern`, but not loaded
257-
by `:test_load_filters`, trigger a warning for a potentially misnamed test file.
258+
functions to ignore by the loader. Any file that is not loaded and not
259+
ignored will emit a warning.
258260
259261
Mix ignores files ending in `_helper.exs` by default, as well as any file
260-
included in the project's `:elixirc_paths`. This ensures that any helper
261-
or test support files are not triggering a warning.
262+
included in the project's `:elixirc_paths`. You may choose to disable all
263+
warnings by ignoring all files with `[fn _ -> true end]`.
262264
263-
Any extra filters configured in the project are appended to the defaults.
264-
Warnings can be disabled by setting this option to `[fn _ -> true end]`.
265265
Paths are relative to the project root and separated by `/`, even on Windows.
266266
267267
## Coloring
@@ -846,16 +846,16 @@ defmodule Mix.Tasks.Test do
846846

847847
defp warn_misnamed_test_files(ignored) do
848848
Mix.shell().info("""
849-
warning: the following files do not match any of the configured `:test_load_filters` / `:test_ignore_filters`:
849+
warning: the following files do not match any of the configured \
850+
`:test_load_filters` / `:test_ignore_filters`:
850851
851852
#{Enum.join(ignored, "\n")}
852853
853-
This might indicate a typo in a test file name (for example, using "foo_tests.exs" instead of "foo_test.exs").
854-
855-
You can adjust which files trigger this warning by configuring the `:test_ignore_filters` option in your
856-
Mix project's configuration. To disable the warning entirely, set that option to [fn _ -> true end].
854+
This might indicate a typo in a test file name (for example, \
855+
using "foo_tests.exs" instead of "foo_test.exs").
857856
858-
For more information, run `mix help test`.
857+
See the configuration for `:test_pattern` under `mix help test` \
858+
for more information.
859859
""")
860860
end
861861

0 commit comments

Comments
 (0)