-
Notifications
You must be signed in to change notification settings - Fork 10
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
Handle coverage the same was as exunit #8
Conversation
This allows the end user to use custom coverage tools.
test_modules(post_config[:erlc_paths], options[:patterns]) | ||
|> Enum.map(&module_name_from_path/1) | ||
|> Enum.drop_while(fn(m) -> | ||
tests_pass?(m, options[:eunit_opts] ++ post_config[:eunit_opts]) end) | ||
if(options[:cover], do: cover_analyse()) | ||
|
||
cover && cover.() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get how this works. It looks like cover is either nil
or a Keyword. How would cover.()
work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cover
is either nil
or a function. Cover.start/2
returns a function that does the analysis and writes the output.
The code for the default Cover
module is here: https://github.com/elixir-lang/elixir/blob/master/lib/mix/lib/mix/tasks/test.ex#L2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so I think this is just a bit of funkyness with variable names (like having a couple things named cover
). Can we do something like
def run(args) do
# .. existing code
# line 55
cover_callback = start_cover_tool(options[:cover], project)
# lines 63-66 same
# line 68
execute_cover_callback(cover_callback)
end
# no cover tool specified
defp start_cover_tool(nil, _project), do: nil
# set up the cover tool
defp start_cover_tool(cover_tool, project) do
compile_path = Mix.Project.compile_path(project)
cover = Keyword.merge(@cover, project[:test_coverage] || [])
# returns a callback
cover[:tool].start(compile_path, cover)
end
# no cover tool was specified
defp execute_cover_callback(nil), do: :ok
# run the cover callback
defp execute_cover_callback(cb), do: cb.()
* master: Replace List.keymember? with Keyword.has_key? Add eunit_formatters for better output Make sure test failures cause the task to fail Run the tests all at once rather than individually # Conflicts: # lib/mix/tasks/eunit.ex
@dantswain Done. Let me know what you think. |
👍 |
This allows the end user to use custom coverage tools.