diff --git a/.travis.yml b/.travis.yml index 2af1d45..8d4e90c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,11 +10,13 @@ language: perl # - DISPLAY=:123 before_install: - sudo apt-get update -qq - - sudo apt-get install -qq xvfb libx11-dev libfreetype6-dev libxft-dev $LIBPNG $LIBZ $LIBJPEG $([ "$WINDOW_MANAGER" = "kwin" ] && echo -n "kde-window-manager" || echo -n $WINDOW_MANAGER) + - sudo apt-get install -qq xvfb libx11-dev $([ "$USE_XFT" = "no" ] || echo -n "libfreetype6-dev libxft-dev") $LIBPNG $LIBZ $LIBJPEG $([ "$WINDOW_MANAGER" = "kwin" ] && echo -n "kde-window-manager" || echo -n $WINDOW_MANAGER) - Xvfb :123 & - (sleep 10; env DISPLAY=:123 $WINDOW_MANAGER) & matrix: include: + - perl: "5.19" + env: DISPLAY=:123 WINDOW_MANAGER=twm ## t/fbox.t fails, not reproducible on a freebsd system # - perl: "5.18" # env: DISPLAY=:123 WINDOW_MANAGER=metacity LIBPNG=libpng-dev LIBZ=libz-dev LIBJPEG=libjpeg-dev @@ -29,4 +31,4 @@ matrix: - perl: "5.10" env: DISPLAY=:123 WINDOW_MANAGER=fvwm LIBPNG=libpng-dev LIBZ=libz-dev LIBJPEG=libjpeg-dev - perl: "5.8" - env: DISPLAY=:123 WINDOW_MANAGER=twm + env: DISPLAY=:123 WINDOW_MANAGER=twm USE_XFT=no diff --git a/myConfig b/myConfig index 02d2ee5..fbc4a46 100755 --- a/myConfig +++ b/myConfig @@ -147,7 +147,12 @@ sub Ift { foreach (map { "$_/freetype2" } @_) { - if (-d $_ && -d "$_/freetype" && -r "$_/freetype/freetype.h") + if (-r "$_/freetype.h") # location in Debian (since jessie) and in newer versions of the FreeBSD port + { + print "Using -I$_ to find $_/freetype/freetype.h\n"; + return "-I$_"; + } + if (-r "$_/freetype/freetype.h") # location in FreeBSD (older versions of freetype2 port) and Debian (up to wheezy) { print "Using -I$_ to find $_/freetype/freetype.h\n"; return "-I$_"; @@ -350,7 +355,7 @@ if ($win_arch eq 'x') { # # Prefer 64bit libraries on certain architectures # - unless (defined $xlib and $Config{'archname'} =~ m/x86_64/) + if (!defined $xlib and $Config{'archname'} =~ m/x86_64/) { $xlib = &lX11(0, chooseX11()); } diff --git a/t/create.t b/t/create.t index 8843acc..5816b1b 100644 --- a/t/create.t +++ b/t/create.t @@ -1,7 +1,7 @@ # -*- perl -*- BEGIN { $|=1; $^W=1; } use strict; -use Test; +use Test::More; ## ## Almost all widget classes: load module, create, pack, and ## destory an instance. @@ -80,37 +80,46 @@ BEGIN ($^O eq 'cygwin' and defined($Tk::platform) and $Tk::platform eq 'MSWin32')); - plan test => (15*@class+3); + plan tests => (15*@class+4); }; +if (!defined &diag) + { + *diag = sub { print "# $_[0]\n" }; + } + eval { require Tk; }; -ok($@, "", "loading Tk module"); +is($@, "", "loading Tk module"); my $mw; eval {$mw = Tk::MainWindow->new();}; -ok($@, "", "can't create MainWindow"); -ok(Tk::Exists($mw), 1, "MainWindow creation failed"); +is($@, "", "No error while creating MainWindow"); +ok(Tk::Exists($mw), "MainWindow creation OK"); eval { $mw->geometry('+10+10'); }; # This works for mwm and interactivePlacement +eval { Tk::MainWindow::Create() }; +isnt($@, '', "no segfault for Tk::MainWindow::Create without args, but an error message"); + my $w; foreach my $class (@class) { - print "Testing $class\n"; + note "Testing $class"; undef($w); eval "require Tk::$class;"; - ok($@, "", "Error loading Tk::$class"); - ok("Tk::$class"->isa('Tk::Widget'),1,"Tk::$class is not a widget"); + is($@, "", "No error loading Tk::$class"); + isa_ok("Tk::$class", 'Tk::Widget', "Tk::$class is a widget"); eval { $w = $mw->$class(); }; - ok($@, "", "can't create $class widget"); - skip($@, Tk::Exists($w), 1, "$class instance does not exist"); + is($@, "", "Can create $class widget"); + ok(Tk::Exists($w), "$class instance exists"); + SKIP: { + skip "Window cannot be created", 6 + if !Tk::Exists($w); - if (Tk::Exists($w)) - { - ok($w->class,$class,"Window class does not match"); + is($w->class,$class,"Window class matches"); if ($w->isa('Tk::Wm')) { @@ -121,30 +130,30 @@ foreach my $class (@class) # geometry and positionfrom do not help eval { $w->positionfrom('user'); }; #eval { $w->geometry('+10+10'); }; - ok ($@, "", 'Problem set postitionform to user'); + is ($@, "", 'No problem set postitionform to user'); eval { $w->Popup; }; - ok ($@, "", "Can't Popup a $class widget") + is ($@, "", "Can Popup a $class widget") } else { - ok(1); # dummy for above positionfrom test + pass("dummy for positionfrom test for non-Wm widgets"); eval { $w->pack; }; - ok ($@, "", "Can't pack a $class widget") + is ($@, "", "Can pack a $class widget") } - print "# $class update\n"; + note "$class update"; eval { $mw->update; }; - ok ($@, "", "Error during 'update' for $class widget"); + is ($@, "", "No error during 'update' for $class widget"); my @dummy; - print "# $class configure list\n"; + note "$class configure list"; eval { @dummy = $w->configure; }; - ok ($@, "", "Error: configure list for $class"); + is ($@, "", "No error while getting configure as list for $class"); my $dummy; - print "# $class configure scalar\n"; + note "$class configure scalar"; eval { $dummy = $w->configure; }; - ok ($@, "", "Error: configure scalar for $class"); - ok (scalar(@dummy),scalar(@$dummy), "Error: scalar config != list config"); + is ($@, "", "No error while getting configure as scalar for $class"); + is (scalar(@dummy),scalar(@$dummy), "Error: scalar config != list config"); $@ = ""; my %skip = (-class => 1); @@ -160,21 +169,21 @@ foreach my $class (@class) eval { $w->configure($val[0],$val[-1]) }; if ($@) { - print "#$class @val:$@"; + diag "$class @val:$@"; last; } } } - ok($@,"","Cannot re-configure $class"); + is($@,"","Re-configure $class"); - print "# $class update post-configure\n"; + note "$class update post-configure"; eval { $mw->update; }; - ok ($@, "", "Error: 'update' after configure for $class widget"); + is ($@, "", "'update' after configure for $class widget"); - print "# $class destroy\n"; + note "$class destroy"; eval { $w->destroy; }; - ok($@, "", "can't destroy $class widget"); - ok(!Tk::Exists($w), 1, "$class: widget not really destroyed"); + is($@, "", "can destroy $class widget"); + ok(!Tk::Exists($w), "$class: widget is really destroyed"); # XXX: destroy-destroy test disabled because nobody vote for this feature # Nick Ing-Simmmons wrote: @@ -191,12 +200,6 @@ foreach my $class (@class) #ok($@, "", "Ooops, destroying a destroyed widget should not complain"); } - else - { - # Widget $class couldn't be created: - # Popup/pack, update, destroy skipped - for (1..6) { skip (1,1,1, "skipped because widget could not be created"); } - } } 1; diff --git a/t/errordialog.t b/t/errordialog.t index 3036e5b..ffd1b71 100755 --- a/t/errordialog.t +++ b/t/errordialog.t @@ -27,21 +27,13 @@ use_ok 'Tk::ErrorDialog'; my $mw = tkinit; $mw->geometry("+10+10"); -my $errmsg = "Intentional error."; -$mw->afterIdle(sub { die "$errmsg\n" }); - my $ed; -$mw->after(100, sub { - my $dialog = search_error_dialog($mw); - isa_ok($dialog, "Tk::Dialog", "dialog"); - $ed = $dialog; - my $error_stacktrace_toplevel = search_error_stacktrace_toplevel($mw); - isa_ok($error_stacktrace_toplevel, 'Tk::ErrorDialog', 'Found stacktrace window'); - is($error_stacktrace_toplevel->state, 'withdrawn', 'Stacktrace not visible'); - $error_stacktrace_toplevel->geometry('+0+0'); # for WMs with interactive placement - $dialog->SelectButton('Stack trace'); - second_error(); - }); + +my $errmsg = "Intentional error."; +$mw->afterIdle(sub { + $mw->after(100, \&first_error); + die "$errmsg\n"; + }); $mw->after(20*1000, sub { if (Tk::Exists($mw)) { @@ -51,6 +43,19 @@ $mw->after(20*1000, sub { }); MainLoop; +# fills $ed +sub first_error { + my $dialog = search_error_dialog($mw); + isa_ok($dialog, "Tk::Dialog", "dialog"); + $ed = $dialog; + my $error_stacktrace_toplevel = search_error_stacktrace_toplevel($mw); + isa_ok($error_stacktrace_toplevel, 'Tk::ErrorDialog', 'Found stacktrace window'); + is($error_stacktrace_toplevel->state, 'withdrawn', 'Stacktrace not visible'); + $error_stacktrace_toplevel->geometry('+0+0'); # for WMs with interactive placement + $dialog->SelectButton('Stack trace'); + second_error(); +} + sub second_error { $mw->afterIdle(sub { die "$errmsg\n" }); $mw->after(100, sub { diff --git a/tkGlue.c b/tkGlue.c index 57f0bca..ae595bf 100644 --- a/tkGlue.c +++ b/tkGlue.c @@ -2370,7 +2370,7 @@ XS(XS_Tk__MainWindow_Create) STRLEN na; Tcl_Interp *interp = Tcl_CreateInterp(); SV **args = &ST(0); - char *appName = SvPV(ST(1),na); + char *appName = items >= 1 ? SvPV(ST(1),na) : ""; int offset = args - sp; int code; if (!initialized)