Update to Elixir 1.20#1635
Conversation
|
This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested. If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos. For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping |
|
Thank you for contributing to Based on the files changed in this PR, it would be good to pay attention to the following details when reviewing the PR:
Automated comment created by PR Commenter 🤖. |
|
I did this PR in a couple of passes, and I think it's worth breaking down the categories of changes I made. TLDR: there are classes of warnings that our CI doesn't catch, and we have some tests that awkwardly overlap with the compiler's job. Failing testsThis one is pretty basic, the compiler changed, so some tests started failing ( Examploid type warningsAlso basic, when compiling an exercise (or rather its exemploid solution) the compiler found some type warnings ( Runtime warningsThese are things like These are tricky, because they don't make the tests fail, even when using I'm not sure what we need to do to catch these errors in the CI, but it would be worth doing, let's open an issue if you agree. Tests type warningsThese are type warnings in test files ( Those are tricky as well because they won't get caught by These are easy to catch, just add the flag, however I didn't do that because it would also break two other concept exercises |
|
Thanks for taking care of Elixir 1.20. It was on my radar too, but I'm glad I can just review a PR instead of doing all of this myself 😁 . I'll do the review in chunks, for now I'm leaving my thoughts about "Tests type warnings"
I think it's because test files are
Yeah, agreed. Let's add it: #1636
This is an interesting problem. I looked at those two tests and asked myself: would a typical learner mess up their code in a way that those tests would catch? For test "cannot eat a completely new item" do
assert_raise Protocol.UndefinedError, fn ->
Edible.eat(%NewItem{}, %Character{})
end
endTo make this test fail, I think they would have needed to implement a fallback to any: https://elixir.hexdocs.pm/main/protocols.html#fallback-to-any For test "display distance raises error when not given struct" do
fake_car = %{
battery_percentage: 100,
distance_driven_in_meters: 0,
nickname: "Fake"
}
assert_raise(FunctionClauseError, fn ->
RemoteControlCar.display_distance(fake_car)
end)
endAll it takes is not using the struct name in the pattern in the function's head: Would it make sense to move this check from a unit test to the analyzer? Or maybe we should find a mechanism to exclude this specific compilation warning from failing the CI? I'll address the rest of the PR later. |
angelikatyborska
left a comment
There was a problem hiding this comment.
All makes sense 💯 I'm lazy and I want to see green CI on the tooling PRs, so I'll let you update all the tooling PRs before reviewing.
| @tag :pending | ||
| test "negative value is an error " do | ||
| assert_raise FunctionClauseError, fn -> CollatzConjecture.calc(-15) end | ||
| end |
There was a problem hiding this comment.
This one doesn't cause compilation warnings? Even though the typespec is pos_integer?
| defp get_parity(data) do | ||
| bit_count = bit_size(data) | ||
| <<value::size(bit_count)>> = data | ||
| <<value::size(^bit_count)>> = data |
There was a problem hiding this comment.
I'm very happy that 1.20 is finding those bugs 💯
In this PR:
I think this is ready, the test runner CI fails, because it needs this branch.
See my comment below for more thoughts.