develooper Front page | perl.perl5.porters | Postings from January 2012

[perl #108470] Term::ReadLine should use AE instead of Tk for event looping

From:
Father Chrysostomos via RT
Date:
January 29, 2012 14:35
Subject:
[perl #108470] Term::ReadLine should use AE instead of Tk for event looping
Message ID:
rt-3.6.HEAD-14510-1327876534-774.108470-15-0@perl.org
On Fri Jan 20 12:02:11 2012, dmcbride@cpan.org wrote:
> On Wednesday January 18 2012 3:44:47 PM you wrote:
> > Unless you can get someone else familiar with this to sign off on
> the
> > patch, I would have to spend some time studying it myself before I
> feel
> > comfortable applying it.
> 
> Not sure who that'd be :-)
> 
> > It would make testing easier if you could avoid non-core modules
> (fewer
> > modules for people to install to make sure they don’t break things).
> 
> Fair enough.  I'll obviously need AE and Tk for the AE and Tk tests,
> but I've
> avoided all other non-core modules.
> 
> > It would make testing even easier if you could use a mock object
> > (preferably in addition to the AE/Tk tests).
> 
> I'm not entirely clear how.  I need to ensure that the loop is called
> at all.
> 
> A couple things I noticed.  First, T::RL::Stub has its own get_line.
> This
> does not honour the tkRunning flag at all.  If I remove it, it's fine.
> My new
> patch does so.
> 
> Second, get_line only calls the event loop prior to any characters
> being
> typed.  That is, once you start typing, the event loop stops.  I
> expect this
> to be a limitation of a "stub" readline.  I do not plan on fixing
> this, though
> it is a bug/limitation.  It would be far too complex for what has been
> a
> trying thread already :-)  A fix could be to have get_line call get_c
> for each
> character (implicitly trying the event loop again), but then it would
> have to
> handle special characters (at least \b and \n, though <- and -> would
> be
> nice).  I'll leave that to another day, as I expect most people that
> are
> running event loops with T::RL are going to be interested in a full RL
> implementation (::Gnu or ::Perl).
> 
> Please find attached the new patch.  It includes the get_line removal
> above
> plus three brand new .t files.  I first attempted to feed stuff in
> through a pipe
> - it wasn't working.  So then I realised that I just need to test that
> the
> event loop is called at all, so I could really exit immediately from
> there.
> Thus, that's what I'm doing here.

With Tk installed, but no X11 environment running, I get this:

couldn't connect to display "/tmp/launch-YF2sgP/org.x:0" at
/Users/sprout/.cpan/build/Tk-804.030-w5ZSVH/blib/lib/Tk/MainWindow.pm
line 53.
MainWindow->new() at t/Tk.t line 27
# Looks like you planned 3 tests but ran 2.
# Looks like your test exited with 2 just after 2.

In case you haven’t guessed, I’m using Mac OS X.  Can you detect that
error and skip the test?  I’ve noticed that Tk passes its own tests with
no X11 running.  I haven’t yet looked to see what it does.

Apart from that, your patch looks fine to me.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=108470



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About