I’m trying to enable the native coverage from OTP 27, but so far nothing has worked.
I’ve added erlc_options: [:debug_info, :line_coverage, {:line_coverage, true}] to the project config and set the environment variable ERL_AFLAGS="+JPcover true", but it didn’t do anything.
I added these lines to a test to see what is happening:
All project modules have :none as the coverage mode, only if I run with :cover that it changes to :line_counters.
Is there a way to have coverage without :cover compiling the modules? Locally :cover compile takes 7 seconds, so I’m trying to find a way to speed it up, or to have coverage without using it.
mix test some_test_file.exs --cover 58.22s user 12.81s system 449% cpu 15.812 total
:cover compiling takes 7 seconds, and then the rest of the time is spent on creating the summary and HTML generation. On CI --cover adds a whole minute, which is the main reason I wanted to enable this native coverage.
I believe cover will use native coverage by default. The native coverage speeds up the time for running tests, it may not necessarily speed up the time for compiling nor building the reports.
No, that’s correct. That will tell the Erlang compiler to instrument the code. However, it seems that the way the Elixir compiler invokes the Erlang compiler, line_coverage instrumentation will not work for Elixir code.