Skip to content
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

Wait for a number of calls feature (#81) #99

Merged
merged 3 commits into from
Aug 17, 2013
Merged

Wait for a number of calls feature (#81) #99

merged 3 commits into from
Aug 17, 2013

Conversation

horkhe
Copy link
Contributor

@horkhe horkhe commented Feb 20, 2013

Provides a family of wait functions that allow you to block test flow until a particular number of matching function calls occurred.

wait(Mod, OptFunc, OptArgsSpec, Timeout)
wait(Times, Mod, OptFunc, OptArgsSpec, Timeout)
wait(Times, Mod, OptFunc, OptArgsSpec, OptCallerPid, Timeout)

@horkhe
Copy link
Contributor Author

horkhe commented Feb 21, 2013

@eproxus I would really appreciate if you could review at least the interface of this feature at your earliest convenience. We are starting to use it extensively in our in-house project and it would be very frustrating if the interface changes after the old one got spread throughout the code.

@chernser
Copy link

@horkhe @eproxus It would be grate to have this feature in main repo - I'm waiting this for my socket_io_erl project. Would I expect it in recent future? Thanks in advance!

@eproxus
Copy link
Owner

eproxus commented Mar 31, 2013

@horkhe Could you rebase this on the latest develop, please?

@horkhe
Copy link
Contributor Author

horkhe commented Mar 31, 2013

Sure, give me a minute...

On Sun, Mar 31, 2013 at 3:07 PM, Adam Lindberg notifications@github.comwrote:

@horkhe https://github.com/horkhe Could you rebase this on the latest
develop, please?


Reply to this email directly or view it on GitHubhttps://github.com//pull/99#issuecomment-15689944
.

@horkhe
Copy link
Contributor Author

horkhe commented Mar 31, 2013

@eproxus it is rebased.

@horkhe
Copy link
Contributor Author

horkhe commented Apr 2, 2013

I changed wait to raise error:timeout rather then return {error, timeout}, for that makes unit tests using it a little bit less verbose. Same thing as you suggested in the capture feature pull request.

@horkhe
Copy link
Contributor Author

horkhe commented Apr 19, 2013

Have you had a chance to look at it?

@horkhe
Copy link
Contributor Author

horkhe commented Apr 21, 2013

@eproxus I simplified the solution. Got rid of one file. Please note that at one moment it is possible to wait for only one function call, which is ok since wait is a blocking call anyway.

@lucaspiller
Copy link

What is happening to this, would love to see it merged in :)

@horkhe
Copy link
Contributor Author

horkhe commented Apr 28, 2013

Basically it is waiting for the code review to be completed.

ok.
wait(Mod, Times, OptFunc, ArgsMatcher, OptCallerPid, Timeout)
when erlang:is_integer(Times) andalso Times > 0 andalso
erlang:is_integer(Timeout) andalso Timeout >= 0 ->
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guards should be moved to the interface function in meck where the first call is made. erlang:is_integer/1 can be only is_integer/1. In fact, the call to is_integer/1 can be eliminated completely by calling erlang:start_timer(round(Timeout), ...) instead.

@horkhe
Copy link
Contributor Author

horkhe commented May 24, 2013

Sorry guys, I have been terribly busy lately and had no time to do anything else but work. Will try to get some time during the coming weekend to address all the comments.

Maxim Vladimirsky and others added 3 commits May 26, 2013 23:20
- Move guards to `meck:wait`;
- Allow `0` call number in `meck:wait`
- Allow waiting from different processes on different or the
  same call patterns;
- Instead of starting a timer do garbage collection of stale
  wait trackers.
@horkhe
Copy link
Contributor Author

horkhe commented Jun 9, 2013

@eproxus I addressed all the comments that you suggested above. Sorry for such a long response time. You can say that I am in your shoes now, that is not working with meck on regular basis as I used to do. In fact I have not written a line of Erlang code for the past couple of months, which is sad. Anyways please review.

Timeout::non_neg_integer()) ->
ok.
wait(Mod, Times, OptFunc, ArgsMatcher, OptCallerPid, Timeout) ->
EffectiveTimeout = case Timeout of
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case statement is not needed since there is a guard on meck:wait/6.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No It is needed because it is not to guard from wrong input, but to make sure that the remote process has chance to respond in case when 0 timeout it specified but the specified number of calls already happened. In that case wait should complete successfully. Previously the caller waited for response from meck_proc but now caller has its own timeout and that is why 0 timeout requires its own case. If you do not get what I am saying that is probably because I am typing an answer having a couple of bears in me :)

@eproxus
Copy link
Owner

eproxus commented Jun 15, 2013

Hmm, maybe you won't like it, but I have a proposal for a different implementation. :-)

I think there is bit too much specific code in this pull request, when probably less code could be spent on a more generic solution. The idea I had was to implement a simple event system in meck (function called, etc.) and then implement the wait function as a client that sets an event filter, waits for X number of events and then returns.

@horkhe
Copy link
Contributor Author

horkhe commented Jun 15, 2013

Honestly man, I do not see a use case for a generic messaging system in a simple mocking library as meck. If you do not mind I would rather suggest accepting existing specific solution since there are users that obviously need that functionality. You can always change the implementation later if you want.

@ghost
Copy link

ghost commented Aug 7, 2013

Is it possible for this to be merged?

@klastochkin
Copy link

@eproxus we really need this features, could you please consider merging it?

@edgurgel
Copy link
Contributor

edgurgel commented Aug 8, 2013

The last tag is one year old :(

Please, give some ❤️ to meck 😄

@horkhe
Copy link
Contributor Author

horkhe commented Aug 8, 2013

Hey Folks, the thing is that after all code inspection comments were addressed the @eproxus suggested a new way to implement this feature, which in my opinion is too much for a mocking library. I neither have time no desire to do that. So if somebody can step in, please, be my guest.

@horkhe
Copy link
Contributor Author

horkhe commented Aug 8, 2013

Everybody, if you would like to see all this or other features that you are missing in meck/master, you got to be proactive: comment on pull requests, features, bugs or create new ones. Your silence makes owners think that you are content with what meck provides to you. Which is totally ok if that is indeed the case, but if it is not... then you need to say that out loud :).

@eproxus
Copy link
Owner

eproxus commented Aug 12, 2013

I'm thinking about making a 0.8 tag (see #108) right now, and include this feature directly in the next following release. Thoughts?

@horkhe
Copy link
Contributor Author

horkhe commented Aug 12, 2013

As far as I understand people express interest in this particular feature, so closing 0.8 without it won't help them. Please consider accepting this implementation and switching to the more generic solution later on. After all we finalized the API of this function. And therefore changing implementation can be done at any time without affecting anybody.

@edgurgel
Copy link
Contributor

@eproxus, looks ok if we think that the last release was 1 year ago. Maybe adding this feature is too much on a single release.

@eproxus
Copy link
Owner

eproxus commented Aug 12, 2013

That's my thinking. There is no stopping us from doing 0.8 now and 0.9 the day after.

@ghost
Copy link

ghost commented Aug 12, 2013

That sounds like a great idea @eproxus!

eproxus added a commit that referenced this pull request Aug 17, 2013
Wait for a number of calls feature (#81 / #99)
@eproxus eproxus merged commit 3d483fb into eproxus:develop Aug 17, 2013
@horkhe
Copy link
Contributor Author

horkhe commented Aug 27, 2013

Maxim Vladimirsky отправил вам приглашение

Твиттер позволяет вам быть в курсе всего происходящего вокруг, а также оставаться на связи с организациями и людьми, которые вам интересны.

Принять приглашение

https://twitter.com/i/9e59e9f7-9948-428e-b742-2e1aa7f1ae15


Это сообщение было отправлено Твиттером от имени его пользователей, которые пригласили вас в Твиттер, указав ваш адрес электронной почты.
Отменить подписку: https://twitter.com/i/o?t=1&iid=89895c5d-a569-413d-942c-12eadc4a8d9a&uid=0&c=IuVwbCB3dgE4wkJkq0uQPrq4VEygSWfi2QbJnGZD17rIhh9RJ8pzSoEUoU%2FRPg8RLhvnm54MTIS6g%2BYhfO7TpdNLjfxSJePYqXmTL1JJ8M0pNBgObdvDVw%3D%3D&nid=9+26

Нужна помощь?
https://support.twitter.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants