Skip to content

mocked modules are not returned to normal state when verify/1 returns #8

@cypherfox

Description

@cypherfox

Sometime after the switch to gen_statem (it may be completelely unconnected to that change) I regularly get errors like the one below.

When inserting a timer:sleep(100) after the em:verify/1 in the previous test of my eunit suite all works fine. I have started to add a sleep after every verify to work around this.

I have had a look at the code, but cannot find a race condition (at least no according to the documentation of the Erlang API functions that are called by erlymock)

=ERROR REPORT==== 29-Nov-2017::18:23:46 ===
** State machine <0.4811.0> terminating
** Last event = {{call,{<0.4809.0>,#Ref<0.4180725794.4003201027.186836>}},
                 {replay,infinity}}
** When server state  = {programming,
                         {state,<0.4809.0>,infinity,
                          [{expectation,#Ref<0.4180725794.4003201027.186833>,
                            {root,#Ref<0.4180725794.4003201027.186829>},
                            quperl_client_event_mgr,new_object,
                            [<<1,2,3,4>>],
                            {return,ok},
                            []},
                           {expectation,#Ref<0.4180725794.4003201027.186831>,
                            {root,#Ref<0.4180725794.4003201027.186829>},
                            quperl_client_cache,create_object,
                            [<<1,2,3,4>>,[{name,"foo"}]],
                            {return,ok},
                            []}],
                          [],
                          [{expectation,#Ref<0.4180725794.4003201027.186835>,
                            {root,#Ref<0.4180725794.4003201027.186829>},
                            quperl_client_event_mgr,fail,
                            [#Fun<quperl_client_util.is_object_id.1>,
                             txn_mgr_terminated],
                            {return,ok},
                            []}],
                          [],[],[],undefined,no_error}}
** Reason for termination = error:{bad_return_from_state_function,
                                   {em_error_module_already_mocked,
                                    quperl_client_event_mgr}}
** Callback mode = state_functions
** Stacktrace =
**  [{gen_statem,parse_event_result,8,[{file,"gen_statem.erl"},{line,1318}]},
     {gen_statem,loop_event,6,[{file,"gen_statem.erl"},{line,1015}]},
     {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions