[erlang-patches] erl_tidy option to print to stdout
Fred Hebert
mononcqc@REDACTED
Mon Jul 15 14:34:47 CEST 2013
Given you're printing with io:format/1, the output will go to the caller
process' group leader
(http://www.erlang.org/doc/man/erlang.html#group_leader-0). My
recommendation would then be to have your test work using the IO
protocol (http://erlang.org/doc/apps/stdlib/io_protocol.html) a bit as
follows:
my_test(_Config) ->
Parent = self(),
spawn_link(fun() ->
erlang:group_leader(self(), Parent),
call_to_pretty_print()
end)
receive
{io_request, From, ReplyAs, {put_chars, _Encoding, Characters}} ->
From ! {io_reply, ReplyAs, ok}. % validate reception
check_for_content(Characters)
after 1000 ->
erlang:error(too_slow)
end.
Make sure to differentiate requests going to you because they're
printingwhat you want, and not because of any other call that is not
related.
Regards,
Fred.
On 07/15, Aaron France wrote:
> Hi,
>
> Besides from cultivating an entire test suite for the erl_tidy module,
> which is outside of the scope for the patch, if I were to provide a test
> for the addition, I would essentially be testing a simple print function.
> Would I not?
>
> Some pointers on what to test would be a great help, otherwise I'm a bit a
> loss as to what to test.
>
> Regards,
> Aaron
>
>
> On Thu, Jul 11, 2013 at 6:54 PM, Andrew Thompson <andrew@REDACTED> wrote:
>
> > On Thu, Jul 11, 2013 at 04:48:12PM +0200, Björn-Egil Dahlberg wrote:
> > > It is great that the new option is documented!
> > >
> > > Especially since syntax_tools is lacking tests, I think it's crucial
> > > that tests are added.
> > >
> > > It is our policy to require tests for all new features unless the
> > > feature is already covered under some other test.
> >
> > Not that I don't applaud this policy, but it can be *extremely*
> > difficult to add new tests to a untested/minimally tested codebase.
> >
> > I know when I've made contributions in the past I've tried to update the
> > test suites where applicable, but when there's no tests I've sort of
> > thrown up my hands and just submitted the patch.
> >
> > I don't know the best solution to this, but pushing all the work on the
> > contributor seems a little unfair. Maybe the OTP team can help out with
> > testing in such cases.
> >
> > Andrew
> > _______________________________________________
> > erlang-patches mailing list
> > erlang-patches@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-patches
> >
> _______________________________________________
> erlang-patches mailing list
> erlang-patches@REDACTED
> http://erlang.org/mailman/listinfo/erlang-patches
More information about the erlang-patches
mailing list