[Proposal] ex_unit --warnings-as-errors option should not prevent tests from running

32 views
Skip to first unread message

Joe

unread,
May 24, 2021, 10:44:27 AM5/24/21
to elixir-lang-core

I find the ex_unit `--warnings-as-errors` option a useful validation step.  However, when developing tests it's not uncommon for me to have made unimportant changes in my code that cause warnings (for example, commenting out a block, causing some aliases to become unused).  This prevents the tests from even running because ExUnit bails out before running tests when warnings are present.  It's easy enough for me to fix the warnings but it's an extra step I'd love to eliminate if possible.

My proposal is, when `--warnings-as-errors` is enabled:

1. Print warnings etc before the tests are run (same as today)
2. Run the tests regardless of there being warnings or not.
3. Fail with non-zero exit code if warnings present or tests failed.  In the case of warnings, use the same helpful message that is printed today.

My hope is that this will help with developer workflow and allow more users to enable the `--warnings-as-errors` option, perhaps with minor adaptation:

```
Compilation failed due to warnings while using the --warnings-as-errors option
```

becomes (something like)...

```
Test run failed due to presence of warnings during compilation while using the --warnings-as-errors option
```

José Valim

unread,
May 24, 2021, 10:49:21 AM5/24/21
to elixir-l...@googlegroups.com
A PR that moves the warning to after tests run will surely be welcome!
Reply all
Reply to author
Forward
0 new messages