http://ppm.activestate.com/beta/author/DUNNIGANJ.html
Errors such as the following:
couldn't connect to display ":0" at
/home/cpan/perl585/.cpanplus/5.8.5/build/Tk-804.028/blib/lib/Tk/MainWindow.pm
line 55.
MainWindow->new() at test.pl line 26
How would I bypass running the GUI test if there is no display to connect to
so that the install tests show pass instead of fail?
Jack
Are those errors specific to ActiveState's ppm build process, or are
you also getting them with cpan-testers ? (I'm thinking that if it's
specific to ActiveState, the correct approach might be to get them to
fix their build environment.)
As regards bypassing the tests, is there some eval() you could run (in
the test script) to pre-determine the availability of the display ?
Cheers,
Rob
> Are those errors specific to ActiveState's ppm build process, or are
> you also getting them with cpan-testers ? (I'm thinking that if it's
> specific to ActiveState, the correct approach might be to get them to
> fix their build environment.)
> As regards bypassing the tests, is there some eval() you could run (in
> the test script) to pre-determine the availability of the display ?
> Cheers,
> Rob
Hi Rob.
No it is not just an Activestate thing. The errors are also shown on CPAN as
well.
http://cpantesters.perl.org/author/DUNNIGANJ.html
I thought it could be as simple as checking if the existence of
$ENV{DISPLAY} - However even though it could be set - it doesn't guarantee
that the window will have permission to be displayed (i.e. xhost
permissions).
I'm thinking that I might have to eval the entire Tk script - but I was
hoping for a more elegant solution. Any other thoughts?
Jack
> I thought it could be as simple as checking if the existence of
> $ENV{DISPLAY} - However even though it could be set - it doesn't guarantee
> that the window will have permission to be displayed (i.e. xhost
> permissions).
And this is quite tricky to check in a portable way...
I am afraid the best one can do is to document it.
On my box (Solaris), this finds where I came from:
$ who am i | perl -ne 'print if s/^.*\((.*)\)$/$1/' | sort -u
but it gets fooled if I jumps two hops (tells only the previous one).
And anyway, nothing guarantees that I can ssh or rsh back to check
xhost.
One could also look for the X display socket?
Marc
You can set up a virtual framebuffer with Xvfb and use it as the
"display" for your GUI
Hi Jack,
you can use Test::More and a SKIP - block, then just test tkinit()
Christoph
use Test::More tests => 17;
BEGIN {use_ok ('Tk');
use_ok ('Tk::MyModule');
}
SKIP:{
my $mw = eval{ tkinit()};
skip 'Tk::MainWindow instantiation failed - skipping Tk-MyModule.t',
15 if $@;
## 15 tests
}#end SKIP
--
use Tk;use Tk::GraphItems;$c=tkinit->Canvas->pack;push@i,Tk::GraphItems->
TextBox(text=>$_,canvas=>$c,x=>$x+=70,y=>100)for(Just=>another=>Perl=>Hacker);
Tk::GraphItems->Connector(source=>$i[$_],target=>$i[$_+1])for(0..2);
$c->repeat(30,sub{$_->move(0,4*cos($d+=3.16))for(@i)});MainLoop
Do you know if Test::More a core module?
Jack
>
> Do you know if Test::More a core module?
>
It was a core module beginning with 5.6.2:
C:\>perl -MModule::CoreList -e "print Module::CoreList-
>first_release('Test::More')"
5.006002
Cheers,
Rob