Skip to content

Commit

Permalink
fixes rt.cpan.org bug 115511, adds regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
tommybutler committed Jul 13, 2016
1 parent 9594817 commit da90585
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
9 changes: 9 additions & 0 deletions File_Util/Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
Revision history for Perl extension File::Util.pm

4.161950 2016-07-12
- This release fixes a critical bug in the list_dir() method, detailed at
https://rt.cpan.org/Public/Bug/Display.html?id=115511
- Regression test added to catch the failure condition
- NOTE: No major code or featureset changes included as part of this release,
therefore it is still deemed "stable", as no significant changes to the code
have been made beyond a two line bugfix that remedies the problem that
caused the list_dir() method to fail under certain conditions.

4.161200 2016-04-29
- The previous TRIAL release passes muster by cpantesters. This is
now released as a STABLE dist, although more features are planned in
Expand Down
5 changes: 5 additions & 0 deletions File_Util/NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
NEWS for File::Util

Tue Jul 12 18:37:17 CDT 2016
Releasing this bug fix to CPAN immediately. Having changed only one line
of code, and knowing the criticality of the bug, I'm releasing this as
GA and skipping the ...-TRIAL dist formalities. Regression test also added.

Thu Jun 6 23:11:39 CDT 2013
Since Sat Mar 2 01:13:46 CST 2013, 580 test runs from the CPAN testers
have had 100% complete PASSes. I'm releasing the code as-is, as
Expand Down
4 changes: 3 additions & 1 deletion File_Util/lib/File/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ sub list_dir {
my $dir = shift @_;
my $opts = ref $_[0] eq 'REF' ? ${ shift @_ } : $this->_remove_opts( \@_ );

my ( @dir_contents, $subdirs, $files );
my @dir_contents;

my ( $subdirs, $files ) = ( [], [] );

my $abort_depth = $opts->{abort_depth};

Expand Down
37 changes: 37 additions & 0 deletions File_Util/t/021_list_dir_regression.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

use strict;
use warnings;

# the original intent of this test was to isolate and test solely the
# list_dir method, but it became immediatley apparent that you can't
# very well test list_dir() unless you have a good directory tree first;
# this led to the combining of the make_dir and list_dir testing routines

use Test::More tests => 2;
use Test::NoWarnings;

use File::Temp qw( tempdir );

use lib './lib';
use File::Util qw( SL NL OS );

# one recognized instantiation setting
my $ftl = File::Util->new( );

my $tempdir = tempdir( CLEANUP => 1 );
my $testbed = $tempdir . SL . $$ . SL . time;
my @test_dirs = qw/ Fin Rey Kylo Poe /;

for my $tdir ( @test_dirs )
{
$ftl->make_dir( $testbed . SL . $tdir )
}

is_deeply
(
[ sort $ftl->list_dir( $testbed ) ],
[ sort qw( . .. ), @test_dirs ],
'regression: plain dir listing with only subdirs present (no files)'
);

exit;

0 comments on commit da90585

Please sign in to comment.