From: Steffen Mueller Date: Thu, 3 Sep 2009 15:10:25 +0000 (+0200) Subject: Move FileCache from lib to ext X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d9268716ae5100c271d6031c5c04fc4b1d4b48ff;p=p5sagit%2Fp5-mst-13.2.git Move FileCache from lib to ext At the same time, remove PERL_CORE logic from tests and convert tests to use Test::More instead of t/test.pl. --- diff --git a/MANIFEST b/MANIFEST index bd45358..4c8531a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -726,6 +726,14 @@ ext/Fcntl/Makefile.PL Fcntl extension makefile writer ext/Fcntl/t/fcntl.t See if Fcntl works ext/Fcntl/t/mode.t See if S_ISREG() and S_ISDIR() work ext/Fcntl/t/syslfs.t See if large files work for sysio +ext/FileCache/lib/FileCache.pm Keep more files open than the system permits +ext/FileCache/t/01open.t See if FileCache works +ext/FileCache/t/02maxopen.t See if FileCache works +ext/FileCache/t/03append.t See if FileCache works +ext/FileCache/t/04twoarg.t See if FileCache works +ext/FileCache/t/05override.t See if FileCache works +ext/FileCache/t/06export.t See if FileCache exporting works +ext/FileCache/t/07noimport.t See if FileCache works without importing ext/File-Fetch/lib/File/Fetch.pm File::Fetch ext/File-Fetch/t/01_File-Fetch.t File::Fetch tests ext/File-Glob/bsd_glob.c File::Glob extension run time code @@ -2486,14 +2494,6 @@ lib/feature.pm Pragma to enable new syntax lib/feature.t See if features work lib/File/Basename.pm Emulate the basename program lib/File/Basename.t See if File::Basename works -lib/FileCache.pm Keep more files open than the system permits -lib/FileCache/t/01open.t See if FileCache works -lib/FileCache/t/02maxopen.t See if FileCache works -lib/FileCache/t/03append.t See if FileCache works -lib/FileCache/t/04twoarg.t See if FileCache works -lib/FileCache/t/05override.t See if FileCache works -lib/FileCache/t/06export.t See if FileCache exporting works -lib/FileCache/t/07noimport.t See if FileCache works without importing lib/File/CheckTree.pm Perl module supporting wholesale file mode validation lib/File/CheckTree.t See if File::CheckTree works lib/File/Compare.pm Emulation of cmp command diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl index 956bcd9..b23e480 100755 --- a/Porting/Maintainers.pl +++ b/Porting/Maintainers.pl @@ -2047,6 +2047,8 @@ package Maintainers; ext/Errno ext/Fcntl/ ext/File-Glob/ + ext/FileCache/lib + ext/FileCache/t ext/GDBM_File/ ext/Hash-Util-FieldHash/ ext/Hash-Util/ @@ -2095,8 +2097,6 @@ package Maintainers; lib/File/Find.pm lib/File/Find/ lib/File/stat.{pm,t} - lib/FileCache.pm - lib/FileCache/ lib/FileHandle.{pm,t} lib/FindBin.{pm,t} lib/Getopt/Std.{pm,t} diff --git a/ext/.gitignore b/ext/.gitignore index 775a62b..78b4a02 100644 --- a/ext/.gitignore +++ b/ext/.gitignore @@ -20,6 +20,7 @@ ppport.h /B-Deparse/Makefile.PL /B-Lint/Makefile.PL /Data-Dumper/Makefile.PL +/FileCache/Makefile.PL /File-Fetch/Makefile.PL /Filter-Simple/Makefile.PL /Filter-Util-Call/Makefile.PL diff --git a/lib/FileCache.pm b/ext/FileCache/lib/FileCache.pm similarity index 100% rename from lib/FileCache.pm rename to ext/FileCache/lib/FileCache.pm diff --git a/ext/FileCache/t/01open.t b/ext/FileCache/t/01open.t new file mode 100644 index 0000000..07e01ba --- /dev/null +++ b/ext/FileCache/t/01open.t @@ -0,0 +1,18 @@ +#!./perl + +use FileCache; + +use vars qw(@files); +BEGIN { @files = qw(foo bar baz quux Foo_Bar) } +END { 1 while unlink @files } + +use Test::More tests => 1; + +{# Test 1: that we can open files + for my $path ( @files ){ + cacheout $path; + print $path "$path 1\n"; + close $path; + } + ok(scalar(map { -f } @files) == scalar(@files)); +} diff --git a/lib/FileCache/t/02maxopen.t b/ext/FileCache/t/02maxopen.t similarity index 57% rename from lib/FileCache/t/02maxopen.t rename to ext/FileCache/t/02maxopen.t index 2f737eb..c95ba73 100644 --- a/lib/FileCache/t/02maxopen.t +++ b/ext/FileCache/t/02maxopen.t @@ -1,27 +1,11 @@ #!./perl -BEGIN { - if( $ENV{PERL_CORE} ) { - chdir 't' if -d 't'; - @INC = qw(../lib); - } -} - -use FileCache maxopen=>2; -use Test; +use FileCache maxopen => 2; use vars qw(@files); -BEGIN { - @files = qw(foo bar baz quux); - chdir 't' if -d 't'; +BEGIN { @files = qw(foo bar baz quux) } +END { 1 while unlink @files } - #For tests within the perl distribution - @INC = '../lib' if -d '../lib'; - END; - plan tests=>5; -} -END{ - 1 while unlink @files; -} +use Test::More tests => 5; {# Test 2: that we actually adhere to maxopen for my $path ( @files ){ diff --git a/lib/FileCache/t/03append.t b/ext/FileCache/t/03append.t similarity index 54% rename from lib/FileCache/t/03append.t rename to ext/FileCache/t/03append.t index 5afc513..f765d44 100644 --- a/lib/FileCache/t/03append.t +++ b/ext/FileCache/t/03append.t @@ -1,27 +1,11 @@ #!./perl -BEGIN { - if( $ENV{PERL_CORE} ) { - chdir 't' if -d 't'; - @INC = qw(../lib); - } -} - -use FileCache maxopen=>2; +use FileCache maxopen => 2; use vars qw(@files); -BEGIN { - @files = qw(foo bar baz quux Foo_Bar); - chdir 't' if -d 't'; +BEGIN { @files = qw(foo bar baz quux Foo_Bar) } +END { 1 while unlink @files } - #For tests within the perl distribution - @INC = '../lib' if -d '../lib'; - END; -} -END{ - 1 while unlink @files; -} - -print "1..2\n"; +use Test::More tests => 2; {# Test 3: that we open for append on second viewing my @cat; @@ -38,8 +22,9 @@ print "1..2\n"; push @cat, do{ local $/; <$path>}; close($path); } - print 'not ' unless scalar grep(/\b3$/m, @cat) == scalar @files; - print "ok 1\n"; + + ok(scalar(grep/\b3$/m, @cat) == scalar(@files)); + @cat = (); for my $path ( @files ){ cacheout $path; @@ -50,6 +35,5 @@ print "1..2\n"; push @cat, do{ local $/; <$path>}; close($path); } - print 'not ' unless scalar grep(/\b33$/m, @cat) == scalar @files; - print "ok 2\n"; + ok(scalar(grep /\b33$/m, @cat) == scalar(@files)); } diff --git a/lib/FileCache/t/04twoarg.t b/ext/FileCache/t/04twoarg.t similarity index 54% rename from lib/FileCache/t/04twoarg.t rename to ext/FileCache/t/04twoarg.t index 40bae6d..0189c46 100644 --- a/lib/FileCache/t/04twoarg.t +++ b/ext/FileCache/t/04twoarg.t @@ -1,19 +1,10 @@ #!./perl -BEGIN { - if( $ENV{PERL_CORE} ) { - chdir 't' if -d 't'; - @INC = qw(../lib); - } -} - use FileCache; -END{ - unlink('foo'); -} +END { unlink('foo') } -print "1..1\n"; +use Test::More tests => 1; {# Test 4: that 2 arg format works, and that we cycle on mode change cacheout '>', "foo"; @@ -21,7 +12,6 @@ print "1..1\n"; cacheout '+>', "foo"; print foo "foo 44\n"; seek(foo, 0, 0); - print 'not ' unless eq "foo 44\n"; - print "ok 1\n"; + ok( eq "foo 44\n"); close foo; } diff --git a/ext/FileCache/t/05override.t b/ext/FileCache/t/05override.t new file mode 100644 index 0000000..7edd5a3 --- /dev/null +++ b/ext/FileCache/t/05override.t @@ -0,0 +1,14 @@ +#!./perl + +use FileCache; + +END { unlink("Foo_Bar") } + +use Test::More tests => 1; + +{# Test 5: that close is overridden properly within the caller + cacheout local $_ = "Foo_Bar"; + print $_ "Hello World\n"; + close($_); + ok(!fileno($_)); +} diff --git a/ext/FileCache/t/06export.t b/ext/FileCache/t/06export.t new file mode 100644 index 0000000..0fafe3b --- /dev/null +++ b/ext/FileCache/t/06export.t @@ -0,0 +1,44 @@ +#!./perl +use vars qw(@funcs $i); + +BEGIN { + # Functions exported by FileCache; + @funcs = qw[cacheout cacheout_close]; + $i = 0; +} + +use Test::More tests => 8; + +# Test 6: Test that exporting both works to package main and +# other packages. Now using Exporter. + +# First, we shouldn't be able to have these in our namespace +# Add them to BEGIN so the later 'use' doesn't influence this +# test +BEGIN { + ok(not __PACKAGE__->can($_)) foreach @funcs; +} + +# With an empty import list, we also shouldn't have them in +# our namespace. +# Add them to BEGIN so the later 'use' doesn't influence this +# test +BEGIN { + use FileCache (); + ok(not __PACKAGE__->can($_)) foreach @funcs; +} + + +# Now, we use FileCache in 'main' +{ + use FileCache; + ok(__PACKAGE__->can($_)) foreach @funcs; +} + +# Now we use them in another package +{ + package X; + use FileCache; + ::ok(__PACKAGE__->can($_)) foreach @main::funcs; +} + diff --git a/lib/FileCache/t/07noimport.t b/ext/FileCache/t/07noimport.t similarity index 71% rename from lib/FileCache/t/07noimport.t rename to ext/FileCache/t/07noimport.t index a6e024d..0de92fe 100644 --- a/lib/FileCache/t/07noimport.t +++ b/ext/FileCache/t/07noimport.t @@ -1,14 +1,6 @@ #!./perl -w -BEGIN { - if( $ENV{PERL_CORE} ) { - chdir 't' if -d 't'; - @INC = qw(../lib); - } -} - -require './test.pl'; -plan( tests => 1 ); +use Test::More tests => 1; # Try using FileCache without importing to make sure everything's # initialized without it. diff --git a/lib/.gitignore b/lib/.gitignore index 9076d3d..ac4264e 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -21,6 +21,7 @@ /Errno.pm /ExtUtils/Miniperl.pm /Fcntl.pm +/FileCache.pm /File/Fetch.pm /File/Glob.pm /File/GlobMapper.pm diff --git a/lib/FileCache/t/01open.t b/lib/FileCache/t/01open.t deleted file mode 100644 index ee207dd..0000000 --- a/lib/FileCache/t/01open.t +++ /dev/null @@ -1,35 +0,0 @@ -#!./perl - -BEGIN { - if( $ENV{PERL_CORE} ) { - chdir 't' if -d 't'; - @INC = qw(../lib); - } -} - -use FileCache; -use vars qw(@files); -BEGIN { - @files = qw(foo bar baz quux Foo_Bar); - chdir 't' if -d 't'; - - #For tests within the perl distribution - @INC = '../lib' if -d '../lib'; - END; -} -END{ - 1 while unlink @files; -} - - -print "1..1\n"; - -{# Test 1: that we can open files - for my $path ( @files ){ - cacheout $path; - print $path "$path 1\n"; - close $path; - } - print "not " unless scalar map({ -f } @files) == scalar @files; - print "ok 1\n"; -} diff --git a/lib/FileCache/t/05override.t b/lib/FileCache/t/05override.t deleted file mode 100644 index b7b4083..0000000 --- a/lib/FileCache/t/05override.t +++ /dev/null @@ -1,23 +0,0 @@ -#!./perl - -BEGIN { - if( $ENV{PERL_CORE} ) { - chdir 't' if -d 't'; - @INC = qw(../lib); - } -} - -use FileCache; - -END{ - unlink("Foo_Bar"); -} -print "1..1\n"; - -{# Test 5: that close is overridden properly within the caller - cacheout local $_ = "Foo_Bar"; - print $_ "Hello World\n"; - close($_); - print 'not ' if fileno($_); - print "ok 1\n"; -} diff --git a/lib/FileCache/t/06export.t b/lib/FileCache/t/06export.t deleted file mode 100644 index 67d5996..0000000 --- a/lib/FileCache/t/06export.t +++ /dev/null @@ -1,64 +0,0 @@ -#!./perl - -BEGIN { - if( $ENV{PERL_CORE} ) { - chdir 't' if -d 't'; - @INC = qw(../lib); - } -} - -BEGIN { - # Functions exported by FileCache; - @funcs = qw[cacheout cacheout_close]; - $i = 0; - - # number of tests - print "1..8\n"; -} - -# Test 6: Test that exporting both works to package main and -# other packages. Now using Exporter. - -# First, we shouldn't be able to have these in our namespace -# Add them to BEGIN so the later 'use' doesn't influence this -# test -BEGIN { - for my $f (@funcs) { - ++$i; - print 'not ' if __PACKAGE__->can($f); - print "ok $i\n"; - } -} - -# With an empty import list, we also shouldn't have them in -# our namespace. -# Add them to BEGIN so the later 'use' doesn't influence this -# test -BEGIN { - use FileCache (); - for my $f (@funcs) { - ++$i; - print 'not ' if __PACKAGE__->can($f); - print "ok $i\n"; - } -} - - -# Now, we use FileCache in 'main' -{ use FileCache; - for my $f (@funcs) { - ++$i; - print 'not ' if !__PACKAGE__->can($f); - print "ok $i\n"; - } -} - -# Now we use them in another package -{ package X; - use FileCache; - for my $f (@main::funcs) { - ++$main::i; - print 'not ' if !__PACKAGE__->can($f); - print "ok $main::i\n"; - } -}