[gimp-perl] Update t/run.t to be much shorter and clearer. Patch by Ed J. This is the last patch from bug #72246
- From: Kevin Cozens <kcozens src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp-perl] Update t/run.t to be much shorter and clearer. Patch by Ed J. This is the last patch from bug #72246
- Date: Thu, 23 Jan 2014 18:49:36 +0000 (UTC)
commit 94c5080a17a6f7e3a02c362b1eeb45e2836a6241
Author: Kevin Cozens <kevin ve3syb ca>
Date: Thu Jan 23 13:41:07 2014 -0500
Update t/run.t to be much shorter and clearer. Patch by Ed J.
This is the last patch from bug #722468 and closes that report.
Makefile.PL | 1 +
config.pl | 2 +-
t/run.t | 201 +++++++++++++++--------------------------------------------
3 files changed, 53 insertions(+), 151 deletions(-)
---
diff --git a/Makefile.PL b/Makefile.PL
index 077fcd1..b0bd169 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -230,6 +230,7 @@ WriteMakefile(
Gtk2 => 1.0,
PDL => 0,
Data::Dumper => 2.0,
+ IO::All => 0,
},
META_MERGE => {
"meta-spec" => { version => 2 },
diff --git a/config.pl b/config.pl
index 03634dd..35d1c77 100644
--- a/config.pl
+++ b/config.pl
@@ -80,7 +80,7 @@ while (($k,$v)=each(%cfg)) {
$GIMPTOOL = expand($GIMPTOOL);
$INTLLIBS = expand($INTLLIBS);
-$gimpplugindir = `$GIMPTOOL --gimpplugindir`;
+chomp($gimpplugindir = `$GIMPTOOL --gimpplugindir`);
$GIMP = expand($GIMP);
$GIMP_INC =~ s%\$topdir%$topdir%g;
diff --git a/t/run.t b/t/run.t
index 4b7acbd..2fe43a8 100644
--- a/t/run.t
+++ b/t/run.t
@@ -1,152 +1,53 @@
use Config;
-use vars qw($EXTENSIVE_TESTS $GIMPTOOL);
-
-# the most complicated thing is to set up a working gimp environment. its
-# difficult at best...
-
-BEGIN {
- $|=1;
-
- if ($ENV{DISPLAY}) {
- print "1..26\n";
- $count=0;
- $Gimp::host = "spawn/";
- } else {
- print "1..0\n";
- exit;
- }
-}
-
-sub ok($;$) {
- print((@_==1 ? shift : $_[0] eq &{$_[1]}) ?
- "ok " : "not ok ", ++$count, "\n");
-}
-
-sub skip($$;$) {
- shift() ? print "ok ",++$count," # skip\n" : &ok;
-}
-
-END {
- system("rm","-rf",$dir);#d##FIXME#
-}
-
-use Cwd;
-
-$dir=cwd."/test-dir";
-
-do './config.pl';
-# Test 1
-ok(1);
-
-$n=!$EXTENSIVE_TESTS;
-
-# Find the installation path that gimptool would choose
-# should look like:
-# /usr/bin/install -c /bin/sh /usr/local/lib/gimp/2.0/plug-ins/sh
-
-# Test 2 Get plugin directory
-skip($n,1,sub {$plugins = `$GIMPTOOL --gimpplugindir`;
- chomp $plugins;
- $plugins = $plugins . '/plug-ins';
- 1;}
- );
-
-# Test 3 (Make sure plug-in directory exists)
-skip($n,1,sub {-d $plugins});
-
-# Test 4 (Make sure script-fu exists so we can symlink with it)
-skip($n,1,sub {-x "$plugins/script-fu"});
-
-# Test 5 (Check that environment is setup and can use the Gimp module)
-use Gimp qw(:auto);
-ok(1);
-
-# Test 6 (check that constants are brought in)
-ok(RGBA_IMAGE || RGB_IMAGE);
-
-# Test 7
-ok(RGB_IMAGE ? 1 : 1); # check for correct prototype
-
-sub tests {
- my($i,$l);
- # Test 15 (OO Syntax for new image)
- skip($n,1,sub{0 != ($i=new Image(10,10,RGB))});
- # Test 16 (check its return value)
- skip($n,1,sub {!!ref $i});
- # Test 17 (Different OO syntax for creating a layer)
- skip($n,1,sub{0 != ($l=$i->layer_new(10,10,RGBA_IMAGE,"new layer",100,VALUE_MODE))});
- # Test 18 (check its return value)
- skip($n,1,sub {!!ref $l});
-
- # Test 19 (Yet another OO syntax)
- skip($n,1,sub{Gimp->image_add_layer($l,0) || 1});
- # Test 20 (check that the layer is named what we expect)
- skip($n,"new layer",sub{$l->get_name()});
- # Test 21 (some painting to test variable length arrays, default value)
- skip($n,1,sub{$l->paintbrush(50,[1,1,2,2,5,3,7,4,2,8],PAINT_CONSTANT,0) || 1});
- # Test 22 (some more to test without default value)
- skip($n,1,sub{$l->paintbrush(30,4,[5,5,8,1],PAINT_CONSTANT,0) || 1});
-
- # Test 23 (call external plugin through Plugin->, use explicit RUN_NONINTERACTIVE)
- skip($n,1,sub{Plugin->sharpen(RUN_NONINTERACTIVE,$i,$l,10) || 1});
- # ok(1);
- # Test 24 (call with maximum fu magic)
- skip($n,1,sub{$l->sharpen(10) || 1});
- # Test 25 (call with little Fu magic, using default RUN_NONINTERACTIVE)
- skip($n,1,sub{Gimp->plug_in_sharpen($i,$l,10) || 1});
- # Test 26 (remove image)
- skip($n,1,sub{$i->delete || 1});
-}
-
-system("rm","-rf",$dir); #d#FIXME
-# Test 8
-ok(1,sub {mkdir $dir,0700});
-
-# copy the Perl-Server
-{
- local(*X,*Y,$/);
- open X,"<Perl-Server" or die "unable to read the Perl-Server";
- my $s = <X>;
- open Y,">$dir/Perl-Server.pl" or die "unable to write the Perl-Server";
- print Y $Config{startperl},"\n",$s,<X>;
- # Test 9
- ok(1);
-}
-# Test 10
-ok(1,sub { chmod 0700,"$dir/Perl-Server.pl" });
-
-# Test 11 (symlink script-fu)
-skip($n,1,sub {symlink "$plugins/script-fu","$dir/script-fu"});
-# Test 12 (symlink sharpen)
-skip($n,1,sub {symlink "$plugins/sharpen","$dir/sharpen"});
-
-# Test 13 (output gimprc)
-ok (
- open RC,">$dir/gimprc" and
- print RC "(show-tips no)\n" and
-# print RC "(gimp_data_dir \"\")\n" and
- print RC "(script-fu-path \"\")\n" and
- print RC "(plug-in-path \"$dir\")\n" and
- close RC
+use strict;
+use File::Temp;
+use Test::More tests => 19;
+use IO::All;
+
+BEGIN { use_ok('Gimp', qw(:auto)); }
+our %cfg;
+require_ok './config.pl';
+
+my $plugins = $cfg{gimpplugindir} . '/plug-ins';
+ok(-d $plugins, 'plugins dir exists');
+ok(-x "$plugins/script-fu", 'script-fu executable');
+
+my $dir = File::Temp->newdir;
+my $perlserver = "$dir/Perl-Server.pl";
+my $s = io("Perl-Server")->all or die "unable to read the Perl-Server";
+$s =~ s/^(#!).*?(\n)/$Config{startperl}$2/;
+ok(io($perlserver)->print($s), 'wrote Perl-Server');
+ok(chmod(0700, $perlserver), 'chmod Perl-Server');
+ok(symlink("$plugins/script-fu", "$dir/script-fu"), 'symlink script-fu');
+ok(symlink("$plugins/sharpen", "$dir/sharpen"), 'symlink sharpen');
+ok (io("$dir/gimprc")->print(<<EOF), 'output gimprc');
+(show-tips no)
+(script-fu-path "")
+(plug-in-path "$dir")
+EOF
+$ENV{GIMP2_DIRECTORY} = $dir;
+
+Gimp::init("spawn/");
+
+ok((my $i = new Image(10,10,RGB)), 'OO Syntax for new image');
+ok(
+ (my $l = $i->layer_new(10,10,RGBA_IMAGE,"new layer",100,VALUE_MODE)),
+ 'Different OO syntax for creating a layer',
);
-
-$ENV{GIMP2_DIRECTORY}=$dir;
-$ENV{PERL5LIB}=cwd."/blib/lib:".cwd."/blib/arch";
-
-if(!$n) {
-# Test 14
- skip($n,1);
- Gimp::init;
- tests;
-} else {
-# Test 14
- skip($n,0);
- tests;
-}
-
-
-
-
-
-
-
+ok(!Gimp->image_add_layer($l,0), 'Yet another OO syntax');
+is("new layer", $l->get_name, 'layer name');
+ok(
+ !$l->paintbrush(50,[1,1,2,2,5,3,7,4,2,8],PAINT_CONSTANT,0),
+ 'some painting with variable length arrays, default value',
+);
+ok(
+ !$l->paintbrush(30,4,[5,5,8,1],PAINT_CONSTANT,0),
+ 'paint without default value',
+);
+ok(
+ !Plugin->sharpen(RUN_NONINTERACTIVE,$i,$l,10),
+ 'call external plugin through Plugin->, use explicit RUN_NONINTERACTIVE',
+);
+ok(!$l->sharpen(10), 'call with maximum fu magic');
+ok(!Gimp->plug_in_sharpen($i,$l,10), 'call plugin using default');
+ok(!$i->delete, 'remove image');
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]