[erlang-questions] testing side effects of asynchronous code
Ignas Vyšniauskas
baliulia@REDACTED
Mon Jan 2 22:56:30 CET 2012
On 2012.01.02 19:57, Gianfranco Alongi wrote:
> Hi - just throwing this out there.
>
> I started thinking about this too and wanted some kind of lib for
> side-effect testing and got only as far as whipping up some basic
> stuff
>
> https://github.com/Gianfrancoalongi/Audit-Collector---A-real-time-version-of-Frame-Axiom/
>
> I didn't have too much time back then and it was mostly a proof of concept
>
> /G
Hmm, this is interesting, I was thinking of abusing the Erlang tracer as
well.
For the question Motiejus raised, could something like this possibly work:
erlang:trace(all, true, [call, {tracer, self()}]),
% I tried all of the flags: global, local and meta, all failed
erlang:trace_pattern({gen_gwserver, ack_sent, 1}, true, [local]),
gateway_api:send(Msg),
receive
{trace, _, _, _} ->
ok % gen_gwserver:ack_sent/1 was called, we can proceed
end,
?assert(Something)
I tried this, but it didn't work. Unfortunately, my understanding of
Erlang's trace mechanism is very poor, so I couldn't work out whether
it's possible to fix it somehow.
Thanks,
Ignas
More information about the erlang-questions
mailing list