Skip to content
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

excoveralls reports function calls interpolated in second line of <> as uncovered #3444

Closed
KronicDeth opened this issue Jun 30, 2015 · 5 comments

Comments

@KronicDeth
Copy link
Contributor

(Opened in response to @josevalim's request on elixir-lang-talk

  1. git clone git@github.com:KronicDeth/excoveralls_string_concatenation.git
  2. cd excoveralls_string_concatenation.git
  3. mix deps.get
  4. MIX_ENV=test mix coveralls.detail | less

Actual

Calls to func are marked as missed (red) when interpolated in second line of a two line string concatenation <>:

 def call_in_map_value do
    %{
      key: "one " <>
           "#{func}" <>
           "three"
    }
  end

  def call_in_unnested do
    "one " <>
    "#{func}" <>
    "three"
  end

  def second_line_interpolation do
    "one " <>
    "#{func}"
  end

screen shot 2015-06-29 at 10 18 50 pm
screen shot 2015-06-29 at 10 19 01 pm

Expected

Calls to func are marked as hit (green).

Other test cases

Call location

func is marked as hit when interpolated in the first line of a two line string concatenation or by itself:

  def single_line_interpolation do
    "#{func}"
  end

  def first_line_interpolation do
    "#{func}" <>
    "three"
  end

screen shot 2015-06-29 at 10 19 58 pm

Interpolated value

Expressions that are compile time constants, such as 1 + 1, are marked as hit:

  def second_line_constant_interpolation do
    "one " <>
    "#{1 + 1}"
  end

screen shot 2015-06-29 at 10 20 30 pm

@josevalim
Copy link
Member

Can you please verify this has been fixed in Elixir master?

@KronicDeth
Copy link
Contributor Author

I don't think it worked.

Doing MIX_ENV=test /Users/luke.imhoff/git/elixir-lang/elixir/bin/mix coveralls.detail with /Users/luke.imhoff/git/elixir-lang/elixir at 6fe7659 I still get the uncovered line from my mailing list post:

screen shot 2015-08-21 at 9 56 20 pm

Do I have to do something other than run mix with the full path to the elixir-lang/elixir to ensure the development copy is used over the homebrew copy? (Note: I did make clean test before running bin/mix.)

@josevalim
Copy link
Member

@KronicDeth No, mix will always use the one in your path. Try this:

MIX_ENV=test /Users/luke.imhoff/git/elixir-lang/elixir/bin/elixir -S /Users/luke.imhoff/git/elixir-lang/elixir/bin/mix coveralls.detail

And then you will run it with elixir. A good way to check is always by calling "mix -v".

@KronicDeth
Copy link
Contributor Author

MIX_ENV=test /Users/luke.imhoff/git/elixir-lang/elixir/bin/elixir -S /Users/luke.imhoff/git/elixir-lang/elixir/bin/mix coveralls.detail worked:

screen shot 2015-08-22 at 6 41 34 pm

... but only after cleaning and rebuilding the project. Originally, I had this error:

screen shot 2015-08-22 at 6 40 30 pm

After doing mix clean, mix deps.cleans, mix deps.get, and then MIX_ENV=test /Users/luke.imhoff/git/elixir-lang/elixir/bin/elixir -S /Users/luke.imhoff/git/elixir-lang/elixir/bin/mix coveralls.detail I got

screen shot 2015-08-22 at 6 38 21 pm

I then added some parentheses

diff --git a/test/controllers/api/v1/user_controller_test.exs b/test/controllers/api/v1/user_controller_test.exs
index c3b68fe..ffca946 100644
--- a/test/controllers/api/v1/user_controller_test.exs
+++ b/test/controllers/api/v1/user_controller_test.exs
@@ -1143,7 +1143,11 @@ defmodule Metasploit.Pro.Api.V1.UserControllerTest do

             with "other user's id" do
               setup context do
-                Dict.put(context, :other_user, Metasploit.Pro.Repo.insert Forge.user :required, %{admin: true})
+                Dict.put(
+                  context,
+                  :other_user,
+                  Metasploit.Pro.Repo.insert Forge.user(:required, %{admin: true})
+                )
               end

               should "GET /api/v1/users/:id", %{conn: conn, other_user: other_user} do

Is it expected that I would have had to recompile when going from 1.0.5 to master?

@josevalim
Copy link
Member

Is it expected that I would have had to recompile when going from 1.0.5 to master?

No. I will work on it. Thanks. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants