antonmi / espec

Elixir Behaviour Driven Development
Other
808 stars 62 forks source link

Fix Elixir 1.11 compilation issues and some warnings #302

Closed andrei-mihaila closed 3 years ago

andrei-mihaila commented 3 years ago

Hi, @antonmi,

This should fix the compilation issues with Elixir 1.11 reported in #301 (might not be the most elegant fix).

I'm not sure why Elixir 1.11 warns about not having meck as an external reference (although it is a dependency). I added it to extra_applications just to suppress the warning.

Might have been a bit too ambitious by adding a credo update and some fixes suggested by it.

Please let me know if this is ok, or if you have suggestions for changes (for example I could create a pull request without the credo change).

antonmi commented 3 years ago

Hey @andrei-mihaila ! Thank you for the PR. For some reason I have

== Compilation error in file lib/mix/utils/stale_compatible.ex ==
** (ArgumentError) record :source does not have the key: :struct_references
    (elixir 1.11.0) lib/record.ex:420: Record.create/4
    (mix 1.11.0) expanding macro: Mix.Compilers.Elixir.source/1
    lib/mix/utils/stale_compatible.ex:230: Mix.Utils.StaleCompatible.dependent_modules/4

wen compiling with erlang 23.1.1 and elixir 1.11.0-otp-23. Any ideas?

andrei-mihaila commented 3 years ago

Hey, @antonmi, that's odd. That's one of the things I changed (in this commit), there should be a reference to :export_references there.

I cloned my repo separately - all seems to work fine. I cloned yours and then pulled from mine - same as above. I have the same Elixir version as you have.

$ elixir -v
Erlang/OTP 23 [erts-11.1.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Elixir 1.11.0 (compiled with Erlang/OTP 23)
antonmi commented 3 years ago

Yeah, it's weird! Let me figure out what's wrong

aratak commented 3 years ago

FYI. The PR is not related to this bug. Got this error during update to 1.11.1 with {:espec, "~> 1.7", only: :test} then google point me here.

antonmi commented 3 years ago

Yeah, it's weird.

antonmi commented 3 years ago

Guys, the issue appeared to be quite simple.

@andrei-mihaila It is here https://github.com/antonmi/espec/blob/37dfc6ef0c5bcf18fa18f9c616af3c96caf0e0e9/lib/mix/utils/stale_compatible.ex#L234

As I understand struct_references was removed from the Mix.Elixir.Compilers struct. https://github.com/elixir-lang/elixir/blob/v1.11.2/lib/mix/lib/mix/compilers/elixir.ex

@andrei-mihaila Could you please fix it in this PR?

andrei-mihaila commented 3 years ago

Hi, @antonmi,

I pushed some fixes for Elixir < 1.11.0. I ran the tests in some of the Elixir versions listed in .travis.yml and the tests passed (wrote my own code that uses bitwalker/alpine-elixir; sorry, don't know how to use the integrated CI in Github).

Hope this fixes the issue you discovered. Any other issues please let me know.

phortx commented 3 years ago
{:espec, git: "https://github.com/antonmi/espec.git", tag: "master", only: [:dev, :test]}
== Compilation error in file lib/mix/utils/stale_compatible.ex ==
** (ArgumentError) record :source does not have the key: :struct_references
    (elixir 1.11.2) lib/record.ex:420: Record.create/4
    (mix 1.11.2) expanding macro: Mix.Compilers.Elixir.source/1
    lib/mix/utils/stale_compatible.ex:230: Mix.Utils.StaleCompatible.dependent_modules/4

:(

antonmi commented 3 years ago

@andrei-mihaila I'm merging your PR. Thank you! ❤️

antonmi commented 3 years ago

@andrei-mihaila @phortx @aratak Guys, I've published v1.8.3 with the fix.

phortx commented 3 years ago

It works. Thank you very much! :)