Skip to content

Commit

Permalink
Remove cover data from original module
Browse files Browse the repository at this point in the history
  • Loading branch information
edgurgel committed Jun 23, 2024
1 parent ea12b00 commit cc8d943
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/mimic/module.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ defmodule Mimic.Module do
:code.delete(module)
:code.purge(original(module))
:code.delete(original(module))
:cover.reset(original(module))
:ok
end

Expand Down
9 changes: 4 additions & 5 deletions test/support/test_cover.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ defmodule Mimic.TestCover do
defp execute do
{:result, results, _fail} = :cover.analyse(:calls, :function)

results =
Enum.filter(results, fn
{{Calculator, _, _}, _} -> true
{{NoStubs, _, _}, _} -> true
mimic_module_cover =
Enum.any?(results, fn
{{Calculator.Mimic.Original.Module, _, _}, _} -> true
_ -> false
end)

expected =
{{Calculator, :add, 2}, 5} in results &&
{{Calculator, :mult, 2}, 5} in results &&
{{NoStubs, :add, 2}, 2} in results
{{NoStubs, :add, 2}, 2} in results && !mimic_module_cover

unless expected do
IO.puts("Cover results are incorrect!")
Expand Down

0 comments on commit cc8d943

Please sign in to comment.