Giter Site home page Giter Site logo

Comments (3)

eproxus avatar eproxus commented on July 17, 2024

Finally got around to looking at this today. I couldn't reproduce it with the simple test on my (faster?) machine, so I had to create this monster version:

-module(mt_reload_test).
-include_lib("eunit/include/eunit.hrl").

-compile(export_all).

proc_fn() ->
    receive
        {do_call, Arg} ->
            ?debugFmt("[~p] called: ~p~n", [self(), mt_app:test_fn(Arg)])
    end,
    proc_fn().

reload_test() ->
    Proc = spawn(fun proc_fn/0),
    meck:new(mt_app, [passtrough]),
    meck:expect(mt_app, test_fn, fun(Arg) -> {mocked, Arg} end),
    spawn(fun() ->
            lists:map(fun(N) ->
                        timer:sleep(1),
                        Proc ! {do_call, N}
                     end, lists:seq(0, 800))
          end),
    [meck:expect(mt_app, test_fn, fun(Arg) -> {mocked2, Arg} end) || _ <- lists:seq(1, 5)],

    timer:sleep(4500),
    ?debugFmt("History: ~p~n",[meck:history(mt_app)]),
    ?assertEqual(801, meck:num_calls(mt_app, test_fn, '_'))
    .

I'm also not sure why the reload case is there, and why we don't store history while reloading is active (history is historical, so it should be stored regardless I think). By removing it, this test passes and it doesn't seem to break any other tests.

from meck.

luos avatar luos commented on July 17, 2024

Hi,

Thanks for checking and for the fix!

from meck.

eproxus avatar eproxus commented on July 17, 2024

@luos Thanks for reporting it and providing a base test case, very much appreciated!

from meck.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.