Commit Graph
650 Commits
Author SHA1 Message Date
José Valim 09dcbf7566 Introduce deprecations scheduled for Elixir v1.20 2025-06-07 21:55:06 +02:00
José Valim 51e160e6f8 Add OTP 28 to CI (#14510) 2025-05-21 13:48:13 +02:00
José Valim 87dd05e5fd Preserve files with no line filter on mix test
Before this patch, if you invoked:

    mix test test/foo_test.exs:13 test/bar_test.exs

We would include a location filter only for foo_test.exs
and no tests in bar_test.exs would run. We now ensure
that the full location of files with line filters are
included as tags, as long as any file is included.

Closes #14445.
2025-04-25 15:33:43 +02:00
José Valim 920a6a0a42 Consistenly apply timeouts across suites (#14444)
Closes #14443.
2025-04-18 12:11:12 +02:00
Rudolf Manusadzhian 7e6e7008f9 Add group to the test context (#14440) 2025-04-17 09:39:44 +02:00
Jonatan Männchen f3e8ceb5aa Implement Test Coverage Reporting (#14343) 2025-04-07 22:37:01 +02:00
Steffen Deusch b08eea70e5 Prevent exits from leaking in ExUnit.CaptureServer (#14348)
When a process that traps exits used ExUnit's log capture functionality,
it would receive stray exits from the Tasks started inside it that could
lead to issues if not handled.
2025-03-19 16:51:28 +01:00
Jean Klingler b3cc618199 Fix regression when diffing nested improper lists (#14292)
Close https://github.com/elixir-lang/elixir/issues/14291
2025-02-21 23:08:36 +09:00
José Valim c1e79d189c Support Erlang/OTP 28 2025-02-20 18:10:23 +01:00
Daniel Kukula c65f9555aa Fix ExUnit list diff bug (#14275) 2025-02-19 08:32:15 +01:00
Daniel Kukula f1bf1b8602 Use newlines and pretty printing in several builtin exceptions (#14269) 2025-02-18 11:39:58 +01:00
Jonatan Männchen f7bbe81ea7 Inline licence info & copyright for test files (#14257) 2025-02-07 20:54:14 +01:00
Jean Klingler 4087560237 Support ellipsis in doctest exceptions (#14233) 2025-01-28 18:48:47 +09:00
eeff 5354a1fc8d Add :inspect_opts option for doctest (#14225)
Closes #14219
2025-01-24 21:29:21 +01:00
Marcus Kruse 661319329e Show hints for mix test --no-color (#14198) 2025-01-18 16:44:52 +01:00
Jean Klingler 059071acdc Fix ExUnit crash when diffing bitstring specifiers (#14161) 2025-01-09 18:26:50 +09:00
José Valim c1c2cf8a65 Type checking of protocol dispatch (#14117) 2024-12-27 19:40:26 +01:00
Kieran 92f1e3777f Omit excluded tests from test count in CLI summary (#14078) 2024-12-23 11:33:47 +01:00
José Valim d78ef17803 Do not run async groups on load and support --repeat-until-failure (#14107) 2024-12-23 10:31:43 +01:00
José Valim 98229529f6 Do not warn for CaseTemplate options, closes #14077 2024-12-17 10:03:40 +01:00
José Valim 64e4b89053 Fix map ordering in earlier Elixir versions 2024-12-06 09:23:10 +01:00
José Valim beaca3b5ad Improve diff printing for when there are nested three-element tuples 2024-12-06 09:13:10 +01:00
José Valim 0174d50d92 Solve map ordering in earlier Erlang/OTP versions 2024-11-17 19:45:52 +01:00
Daniel Kukula a8c92060ea Format inserted/deleted maps in list assertions (#13954) 2024-11-17 14:09:10 +01:00
José Valim cb2e03688e Perform return type inference and application across local calls (#13984) 2024-11-11 23:06:31 +01:00
José Valim 485ca72ae2 Infer types and use them across remote calls (#13981)
This also unifies handling of deterministic builds with Erlang/OTP
as well as warnings_as_errors.
2024-11-09 18:00:27 +01:00
José Valim 8ed104d175 Add test_pid tag to ExUnit.Case
Closes #13880.
2024-11-07 21:05:04 +01:00
José Valim 1ca06361b6 Type checking of stacktrace and error/raise functions 2024-11-05 13:13:59 +01:00
José Valim 268bb2df93 Provide more hints on missing module message (#13933) 2024-10-28 17:26:22 +01:00
José Valim a0e061f94a Fix warnings during suite 2024-10-27 11:34:40 +01:00
Jean Klingler e7ec9a0d08 prune_metadata keeps delimiters (#13911) 2024-10-17 15:38:22 +09:00
José Valim 8ef2684e3a Avoid timing issues in CI 2024-10-13 20:37:24 +02:00
José Valim 3320a11456 Ensure sync tests are executed 2024-10-13 18:23:29 +02:00
Dino Kovač 7190f41cc9 Support :group option in ExUnit (#13897)
Tests in the same group cannot run concurrently,
but it can run concurrently with other groups.
2024-10-13 16:31:24 +02:00
José Valim 4b4d2cb3ff Ensure async property is preserved when not given 2024-10-10 12:10:15 +02:00
Jean Klingler 5137c33098 Do not allow guards in assert/1 (#13817) 2024-09-09 17:42:11 +09:00
Jean Klingler 9b9ab9948f Fix: Macro.expand/2 should not expand __ENV__ on :match context (#13807) 2024-09-06 16:23:38 +09:00
Jean Klingler 1286a6257f Replace unless/2 usages in the codebase (#13808) 2024-09-06 16:22:51 +09:00
José Valim 99be673c3a Taint failure manifest if requiring or compiling tests fail, closes #13728 2024-07-30 13:12:44 +02:00
Steffen Deusch 63d0932304 Add test for mix test --only async/sync filter (#13651) 2024-06-10 23:07:21 +02:00
José Valim ecac839810 Load async and module tags in runner, closes #13639 2024-06-09 23:53:15 +02:00
José Valim ab7de3a779 Generate different tmp_dir for parameterized tests 2024-06-09 23:01:15 +02:00
Steffen Deusch 844c4c30de use a :queue to store modules in ExUnit.Server (#13636)
In order to have more deterministic test runs when using `--max-cases 1`
and `--max-requires 1` (https://github.com/elixir-lang/elixir/pull/13635)
(see also https://github.com/elixir-lang/elixir/pull/13589), we need to
run tests in compilation order (FIFO).

In the past, ExUnit.Server appended new tests to the front of a list,
which would result in the most recently added test to be run first.

Let's quickly demonstrate the problem this causes for deterministic runs
with a simple example:

Imagine a test (let's call if FooTest) that takes a non-deterministic
amount of time to run. For now let's assume that it sometimes takes 1
second and sometimes up to 5. And as async tests execute in parallel with
compilation of other test files, we could have the following scenario:

FooTest is compiled and because it's async it is immediately started.
It takes 1 second to run.
In this 1 second two more tests are compiled. First BarTest is prepended
to the list, then BazTest.
The order of test runs now is:

FooTest, BazTest, then whatever is last compiled while BazTest runs, ...

Now another run, FooTest takes 5 seconds to run.
While FooTest runs, more than two other tests are compiled.
The order of test runs is:

FooTest, LastCompiledTest, SecondLastCompiledTest, ..., BazTest, BarTest

This can be fixed either by appending new test modules to the end of the
list, or - and that's what this commit does - by using a `:queue`
instead.
2024-06-05 11:21:07 +02:00
José Valim b665ddd6db Add parameterized tests (#13618)
Sometimes you want to run the same tests but with different parameters.
In ExUnit, it is possible to do so by passing a `:parameterize` key to
`ExUnit.Case`. The value must be a list of maps which will be the
parameters merged into the test context.

For example, Elixir has a module called `Registry`, which can have type
`:unique` or `:duplicate`, and can control its concurrency factor using
the `:partitions` option. If you have a number of tests that *behave the
same* across all of those values, you can parameterize those tests with:

    use ExUnit.Case,
      async: true,
      parameterize:
        for(kind <- [:unique, :duplicate],
            partitions <- [1, 8],
            do: %{kind: kind, partitions: partitions})

Then, in your tests, you can access the parameters as part of the context:

    test "starts a registry", %{kind: kind, partitions: partitions} do
      ...
    end

Use parameterized tests with care:

  * Although parameterized tests run concurrently when `async: true` is also given,
    abuse of parameterized tests may make your test suite slower

  * If you use parameterized tests and then find yourself adding conditionals
    in your tests to deal with different parameters, then parameterized tests
    may be the wrong solution to your problem. Consider creating separated
    tests and sharing logic between them using regular functions
2024-05-29 15:44:16 +02:00
José Valim a7cd3647e8 Port custom exceptions to ArgumentError
Those exceptions are not meant to be rescued,
so there is no benefit into providing a custom
module for them.
2024-05-29 11:23:04 +02:00
José Valim 1b7a7341e1 Improve ExUnit Callbacks docs 2024-05-29 10:53:13 +02:00
José Valim 1a9462362c Expose failures_manifest_path 2024-05-10 15:53:41 +02:00
Jean Klingler 8e4a0aae0d Replace semi-column by comma before otherwise (#13535) 2024-05-05 01:26:31 +09:00
José Valim 5422815fde Include max cases in ExUnit reports (#13521)
Some CI environments may report the wrong number
of cores to the Erlang VM. So we choose to print
the number of max cases along side the seed
(both which affect randomness of tests) at the
top of each suite.
2024-05-02 11:09:32 +02:00
Jean Klingler 47ee0236c8 Warn when using @tag outside of describe (#13415) 2024-03-18 06:59:10 +09:00