Skip to content

CLI: Error on compiler warnings in tests #12894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 4, 2024
Merged

Conversation

the-mikedavis
Copy link
Collaborator

This is similar to #10459 but focused on make instead. #10459 also only focused on warnings in lib/ files while this change causes CLI tests to fail when the test modules contain warnings. We need to add the --warnings-as-errors flag to mix test (added in Elixir 1.12). We can at the same time check that the lib/ files compile without warning by compiling with --warnings-as-errors as well.

Most compiler warnings fixed were benign. The shadowing diagnostics like unused bindings are useful though - one fix covered an unused binding that should've been a match (i.e. needed the pin operator ^).

This previously emitted a warning because Elixir will rebind `this_node`
by default, so the `this_node` binding in the line above was unused.
(As opposed to Erlang which would treat this as a match - rejecting
the binding if `this_node` was not equal to the value being matched.)
The node needed to be adjusted as well - `node()` returned the ExUnit
runner's node while the command returned the remote node, which is
stored in the context under `opts.node`.
This check is expected to succeed and the status is expected to be
printed to stdout rather than stderr. This change silences the status
output. The status text was printed mistakenly previously because we
captured stderr rather than stdout.
@the-mikedavis the-mikedavis self-assigned this Dec 4, 2024
@mergify mergify bot added the make label Dec 4, 2024
@michaelklishin
Copy link
Collaborator

@the-mikedavis do I understand it correctly that this change will be effective for gmake tests and not gmake dialyze? The latter is looking for .erl files and in the case of CLI, of course, it won't find any.

@the-mikedavis
Copy link
Collaborator Author

the-mikedavis commented Dec 4, 2024

Yeah this should be limited to test and tests targets. I don't believe we use the dialyze target for the CLI currently. There is the dialyxir project that adds a mix dialyze task we could use that works on Elixir files though.

Edit: a run of make -C deps/rabbitmq_cli dialyze errors out:

dialyzer: Analysis failed with error:
No .erl files to analyze

@michaelklishin michaelklishin added this to the 4.1.0 milestone Dec 4, 2024
@michaelklishin michaelklishin merged commit 9fb0136 into main Dec 4, 2024
271 checks passed
@michaelklishin michaelklishin deleted the md/cli-warnings branch December 4, 2024 19:41
mergify bot pushed a commit that referenced this pull request Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants