Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fix bad match error when cover data file not exists. #60

Closed
wants to merge 2 commits into from

2 participants

@coolluck

It's quite minor fix.
Sometimes a test with meck would fail when cover data file didn't generate by any reason.

@eproxus
Owner

Hmm, this will still fail with a case-clause error. Can you give me anymore hints on how to reproduce the error?

@coolluck

I apologize for late reply.
This error may occur the same mocked module in two or more tests.
It's somewhat rare case, actually.

                    {{case_clause,
                      {error,
                       {cant_open_file,"manager.coverdata",
                        enoent}}},
                     [{meck,restore_original,3,
                       [{file,"src/meck.erl"},{line,680}]},
@eproxus
Owner

This justs adds a print statement when it fails, I think a normal badmatch will suffice for detecting this case. Together with line numbers in exceptions in R15 it should be easy to track down.

I'd appreciate a patch to fix the original problem, so please open another pull request if you have a clue of how to fix it. Alternatively open an issue with instructions of how to reproduce the error.

@eproxus eproxus closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 6, 2012
Commits on Apr 20, 2012
  1. fix case clause failure

    Minsu Choi authored
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/meck.erl
View
8 src/meck.erl
@@ -676,8 +676,12 @@ restore_original(Mod, {File, Data, Options}, WasSticky) ->
cover:compile_beam(File)
end,
restick_original(Mod, WasSticky),
- ok = cover:import(Data),
- ok = file:delete(Data),
+ case cover:import(Data) of
+ ok ->
+ ok = file:delete(Data);
+ {error, Reason} ->
+ io:format("Cover import failure : ~p~n", [Reason])
+ end,
ok.
unstick_original(Module) -> unstick_original(Module, code:is_sticky(Module)).
Something went wrong with that request. Please try again.