How to capture all output to console during Common Test?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to capture all output to console during Common Test?

Max Lapshin-2
Hi.

I'm running ct_run  and want somehow to capture all output made to console (io:format,  ct:print).  Is it possible?

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to capture all output to console during Common Test?

Fred Hebert-2
On 06/09, Max Lapshin wrote:
>Hi.
>
>I'm running ct_run  and want somehow to capture all output made to console
>(io:format,  ct:print).  Is it possible?

I ended up doing this for rebar3 through the cth_readable library. The
only practical way I found to hijack all traffic was to use a parse
transform to replace the function and tunnel it through my own.

Here's the parse transform I used for ct:pal/2-3 :
https://github.com/ferd/cth_readable/blob/master/src/cth_readable_transform.erl

https://github.com/ferd/cth_readable/blob/master/src/cth_readable_failonly.erl 
shows how I got to capture and redirect most of lager and error_logger's
traffic as well, but it's fairly messy.

Regards,
Fred.
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to capture all output to console during Common Test?

Vladimir Gordeev
Well, it's possible to start your own Erlang IO server, start it in ct hook during init, and then make it as a group leader for root ct process.

http://erlang.org/doc/apps/stdlib/io_protocol.html

So just start your own process that handles io_reply, io_request, and then

erlang:group_leader(MyCustomIOServerPid, CtRootPid),

On Sat, Jun 10, 2017 at 4:09 AM, Fred Hebert <[hidden email]> wrote:
On 06/09, Max Lapshin wrote:
Hi.

I'm running ct_run  and want somehow to capture all output made to console
(io:format,  ct:print).  Is it possible?

I ended up doing this for rebar3 through the cth_readable library. The only practical way I found to hijack all traffic was to use a parse transform to replace the function and tunnel it through my own.

Here's the parse transform I used for ct:pal/2-3 :
https://github.com/ferd/cth_readable/blob/master/src/cth_readable_transform.erl

https://github.com/ferd/cth_readable/blob/master/src/cth_readable_failonly.erl shows how I got to capture and redirect most of lager and error_logger's traffic as well, but it's fairly messy.

Regards,
Fred.
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to capture all output to console during Common Test?

Marco Molteni
In reply to this post by Max Lapshin-2
On 9 Jun 2017, at 18:06, Max Lapshin <[hidden email]> wrote:

> I'm running ct_run  and want somehow to capture all output made to console (io:format,  ct:print).  Is it possible?

I wrote mock_io [1] to capture/inject I/O for EUnit. If it doesn't work out of the box with CT, it should be easy to adapt, I'll be happy to accept patches :-)

marco

[1] https://github.com/marco-m/mock_io
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to capture all output to console during Common Test?

Éric Pailleau
In reply to this post by Max Lapshin-2
Le 09/06/2017 à 18:06, Max Lapshin a écrit :
> Hi.
>
> I'm running ct_run  and want somehow to capture all output made to
> console (io:format,  ct:print).  Is it possible?

>
Hi max,

you may have a look to  io_server/0 and io_server/1 in
https://github.com/erlang/otp/blob/master/lib/observer/src/observer_procinfo.erl

was done to catch 'rb' output in observer.

cheers
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to capture all output to console during Common Test?

Max Lapshin-2
In reply to this post by Vladimir Gordeev


On Sat, Jun 10, 2017 at 10:14 AM, Vladimir Gordeev <[hidden email]> wrote:
Well, it's possible to start your own Erlang IO server, start it in ct hook during init, and then make it as a group leader for root ct process.

http://erlang.org/doc/apps/stdlib/io_protocol.html

So just start your own process that handles io_reply, io_request, and then

erlang:group_leader(MyCustomIOServerPid, CtRootPid),


Have you tried to do it?

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to capture all output to console during Common Test?

Vladimir Gordeev
Have you tried to do it?

Yeah, I captured by such manner all IO from custom erlang shell that I started by shell:start/2.
I didn't tried to do it with Common Test though.

Here is module of my own IO server process, just for example: https://gist.github.com/vladimir-vg/ab5a2096759e24e8f6d51386f043430e

On Tue, Jun 13, 2017 at 10:56 PM, Max Lapshin <[hidden email]> wrote:


On Sat, Jun 10, 2017 at 10:14 AM, Vladimir Gordeev <[hidden email]> wrote:
Well, it's possible to start your own Erlang IO server, start it in ct hook during init, and then make it as a group leader for root ct process.

http://erlang.org/doc/apps/stdlib/io_protocol.html

So just start your own process that handles io_reply, io_request, and then

erlang:group_leader(MyCustomIOServerPid, CtRootPid),


Have you tried to do it?


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Loading...