pmonson711

pmonson711

Surprising lines missing from coverage results

Hey Elixir-land!

It’s been a while since I’ve been around. Getting back into lots of elixir work and I found something unexpected regarding the coverage system. Essentially function calls wrapped in literals don’t seem to get counted as coverable statements.

Steps to reproduce:

  1. run mix new coverage_why
  2. paste in lib/coverage_why.ex
defmodule CoverageWhy do
  def hello do
    :world
  end

  def i_has_coverage do
    hello()
  end

  def i_has_no_coverage do
    {:ok, hello()}
  end

  def i_has_no_coverage_as_well do
    [hello()]
  end

  def i_has_no_coverage_as_either do
    [hello()]

    :ok
  end
end
  1. run mix test --cover

I get the results of

Expectations

I would expect all the lines except the original def hello... to be uncovered. If I had to guess the wrapping the call in a literal causes the function call to be inlined somehow. Is this the expected coverage results and is it documented anywhere?

Marked As Solved

josevalim

josevalim

Creator of Elixir

Please open up a bug report, we can likely fix the tuple and list ones, but not the atom because literals do not have line numbers in the AST.

EDIT: I have fixed this locally and I will push it soon.

15
Post #2

Also Liked

josevalim

josevalim

Creator of Elixir

Yup, I could reproduce it. Fixes coming to Elixir master shortly.

josevalim

josevalim

Creator of Elixir

They are not missing per se. If the pattern was covered, then by definition what immediately follows the pattern is being covered too. We can’t highlight it because we don’t have precise line information, but the coverage of the pattern is enough in those cases.

pmonson711

pmonson711

Amazed with your response!

josevalim

josevalim

Creator of Elixir

What is your Elixir version? We have improved this in more recent releases.

semmitmondo

semmitmondo

I tried it with Elixir 1.12.2 and 1.12.3 (on Erlang/OTP 23.2.3). Also tried it with 1.12.3 on Erlang/OTP 24.0.6.
:ok and {:error, :reason} lines are not included in coverage reports on these versions for me. :frowning:

Where Next?

Popular in Questions Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
Fl4m3Ph03n1x
Background Let’s assume I have a typical GenServer that receives messages as requests, does some operation in a DB and returns responses....
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
kostonstyle
Hi all I want to have a unix time, from the current time plus 1 hour. DateTime.now + 1 hour How to get it in elixir? Thanks
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Other popular topics Top

openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement