r32179 - in /branches/upstream/libtest-fixme-perl: ./ current/ current/lib/ current/lib/Test/ current/t/ current/t/dirs/ current/t/dirs/deep/ current/t/dirs/deep/one/ current/t/dirs/deep/two/ current/t/dirs/normal/ current/t/dirs/types/

rmayorga at users.alioth.debian.org rmayorga at users.alioth.debian.org
Wed Mar 18 03:14:28 UTC 2009


Author: rmayorga
Date: Wed Mar 18 03:14:18 2009
New Revision: 32179

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=32179
Log:
[svn-inject] Installing original source of libtest-fixme-perl

Added:
    branches/upstream/libtest-fixme-perl/
    branches/upstream/libtest-fixme-perl/current/
    branches/upstream/libtest-fixme-perl/current/Changes
    branches/upstream/libtest-fixme-perl/current/MANIFEST
    branches/upstream/libtest-fixme-perl/current/META.yml
    branches/upstream/libtest-fixme-perl/current/Makefile.PL
    branches/upstream/libtest-fixme-perl/current/README
    branches/upstream/libtest-fixme-perl/current/lib/
    branches/upstream/libtest-fixme-perl/current/lib/Test/
    branches/upstream/libtest-fixme-perl/current/lib/Test/Fixme.pm
    branches/upstream/libtest-fixme-perl/current/t/
    branches/upstream/libtest-fixme-perl/current/t/check_project.t
    branches/upstream/libtest-fixme-perl/current/t/dirs/
    branches/upstream/libtest-fixme-perl/current/t/dirs/deep/
    branches/upstream/libtest-fixme-perl/current/t/dirs/deep/deep_a.txt
    branches/upstream/libtest-fixme-perl/current/t/dirs/deep/deep_b.txt
    branches/upstream/libtest-fixme-perl/current/t/dirs/deep/one/
    branches/upstream/libtest-fixme-perl/current/t/dirs/deep/one/deep_one_a.txt
    branches/upstream/libtest-fixme-perl/current/t/dirs/deep/one/deep_one_b.txt
    branches/upstream/libtest-fixme-perl/current/t/dirs/deep/two/
    branches/upstream/libtest-fixme-perl/current/t/dirs/deep/two/deep_two_a.txt
    branches/upstream/libtest-fixme-perl/current/t/dirs/deep/two/deep_two_b.txt
    branches/upstream/libtest-fixme-perl/current/t/dirs/normal/
    branches/upstream/libtest-fixme-perl/current/t/dirs/normal/four.pod
    branches/upstream/libtest-fixme-perl/current/t/dirs/normal/one.txt
    branches/upstream/libtest-fixme-perl/current/t/dirs/normal/three.pm
    branches/upstream/libtest-fixme-perl/current/t/dirs/normal/two.pl
    branches/upstream/libtest-fixme-perl/current/t/dirs/types/
    branches/upstream/libtest-fixme-perl/current/t/dirs/types/normal.txt
    branches/upstream/libtest-fixme-perl/current/t/format_results.t
    branches/upstream/libtest-fixme-perl/current/t/list_files.t
    branches/upstream/libtest-fixme-perl/current/t/load_file.t
    branches/upstream/libtest-fixme-perl/current/t/scan_file.t
    branches/upstream/libtest-fixme-perl/current/t/skip_all.t
    branches/upstream/libtest-fixme-perl/current/t/test-fixme.t

Added: branches/upstream/libtest-fixme-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/Changes?rev=32179&op=file
==============================================================================
--- branches/upstream/libtest-fixme-perl/current/Changes (added)
+++ branches/upstream/libtest-fixme-perl/current/Changes Wed Mar 18 03:14:18 2009
@@ -1,0 +1,16 @@
+Changes
+
+0.04 - Thu 12 Mar 2009 22:51:51 GMT
+     - Added copyright info
+
+0.03 - Wed Jun 11 19:24:59 BST 2008
+     - version bump to release to CPAN§
+
+0.02_01 - Tue, 10 Jun 2008 15:11:01 -0400 dmo
+	- allow list of directory names to be specified in 'where' argument
+	- add 'filename_match' argument to filter for desired filenames
+
+0.02 - switched to makemaker
+       changed tests to give better errors
+       filter out CVS and Subversion files from those tested
+

Added: branches/upstream/libtest-fixme-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/MANIFEST?rev=32179&op=file
==============================================================================
--- branches/upstream/libtest-fixme-perl/current/MANIFEST (added)
+++ branches/upstream/libtest-fixme-perl/current/MANIFEST Wed Mar 18 03:14:18 2009
@@ -1,0 +1,24 @@
+Changes
+lib/Test/Fixme.pm
+Makefile.PL
+MANIFEST			This list of files
+README
+t/check_project.t
+t/dirs/deep/deep_a.txt
+t/dirs/deep/deep_b.txt
+t/dirs/deep/one/deep_one_a.txt
+t/dirs/deep/one/deep_one_b.txt
+t/dirs/deep/two/deep_two_a.txt
+t/dirs/deep/two/deep_two_b.txt
+t/dirs/normal/four.pod
+t/dirs/normal/one.txt
+t/dirs/normal/three.pm
+t/dirs/normal/two.pl
+t/dirs/types/normal.txt
+t/format_results.t
+t/list_files.t
+t/load_file.t
+t/scan_file.t
+t/skip_all.t
+t/test-fixme.t
+META.yml                                 Module meta-data (added by MakeMaker)

Added: branches/upstream/libtest-fixme-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/META.yml?rev=32179&op=file
==============================================================================
--- branches/upstream/libtest-fixme-perl/current/META.yml (added)
+++ branches/upstream/libtest-fixme-perl/current/META.yml Wed Mar 18 03:14:18 2009
@@ -1,0 +1,17 @@
+--- #YAML:1.0
+name:                Test-Fixme
+version:             0.04
+abstract:            ~
+license:             ~
+generated_by:        ExtUtils::MakeMaker version 6.32
+distribution_type:   module
+requires:     
+    Carp:                          0
+    ExtUtils::MakeMaker:           0
+    File::Finder:                  0
+    File::Slurp:                   0
+    Test::Builder:                 0
+    Test::More:                    0
+meta-spec:
+    url:     http://module-build.sourceforge.net/META-spec-v1.2.html
+    version: 1.2

Added: branches/upstream/libtest-fixme-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/Makefile.PL?rev=32179&op=file
==============================================================================
--- branches/upstream/libtest-fixme-perl/current/Makefile.PL (added)
+++ branches/upstream/libtest-fixme-perl/current/Makefile.PL Wed Mar 18 03:14:18 2009
@@ -1,0 +1,17 @@
+use strict;
+use warnings;
+
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+    'NAME'         => 'Test::Fixme',
+    'VERSION_FROM' => 'lib/Test/Fixme.pm',
+    'PREREQ_PM'    => {
+        'Carp'                => 0,
+        'ExtUtils::MakeMaker' => 0,
+        'File::Finder'        => 0,
+        'File::Slurp'         => 0,
+        'Test::Builder'       => 0,
+        'Test::More'          => 0,
+    },
+);

Added: branches/upstream/libtest-fixme-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/README?rev=32179&op=file
==============================================================================
--- branches/upstream/libtest-fixme-perl/current/README (added)
+++ branches/upstream/libtest-fixme-perl/current/README Wed Mar 18 03:14:18 2009
@@ -1,0 +1,64 @@
+NAME
+    Test::Fixme - check code for FIXMEs.
+
+SYNOPSIS
+        # In a test script like 't/test-fixme.t'
+        use Test::Fixme;
+        run_tests();
+
+        # You can also tailor the behaviour.
+        use Test::Fixme;
+        run_tests( where    => 'lib',      # where to find files to check
+                   match    => 'TODO',     # what to check for
+                   skip_all => $ENV{SKIP}  # should all tests be skipped
+        );
+
+DESCRIPTION
+    When coding it is common to come up against problems that need to be
+    addressed but that are not a big deal at the moment. What generally
+    happens is that the coder adds comments like:
+
+     # FIXME - what about windows that are bigger than the screen?
+
+     # FIXME - add checking of user priviledges here.
+
+    Test::Fixme allows you to add a test file that ensures that none of
+    these get forgotten in the module.
+
+  Arguments
+    By default run_tests will search for 'FIXME' in all the files it can
+    find in the project. You can change these defaults by using 'where' or
+    'match' as follows:
+
+        run_tests( where => 'lib', # just check the modules.
+                   match => 'TODO' # look for things that are not done yet.
+        );
+
+HINTS
+    If you want to match something other than 'FIXME' then you may find that
+    the test file itself is being caught. Try doing this:
+
+        run_tests( match => 'TO'.'DO' );
+
+    You may also wish to suppress the tests - try this:
+
+        use Test::Fixme;
+        run_tests( skip_all => $ENV{SKIP_TEST_FIXME} );
+
+    You can only run run_tests once per file. Please use several test files
+    if you want to run several different tests.
+
+SEE ALSO
+    Devel::FIXME
+
+AUTHOR
+    Edmund von der Burg <evdb at ecclestoad.co.uk>
+
+    Please let me know if you have any comments or suggestions.
+
+    <http://ecclestoad.co.uk/>
+
+LICENSE
+    This library is free software . You can redistribute it and/or modify it
+    under the same terms as perl itself.
+

Added: branches/upstream/libtest-fixme-perl/current/lib/Test/Fixme.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/lib/Test/Fixme.pm?rev=32179&op=file
==============================================================================
--- branches/upstream/libtest-fixme-perl/current/lib/Test/Fixme.pm (added)
+++ branches/upstream/libtest-fixme-perl/current/lib/Test/Fixme.pm Wed Mar 18 03:14:18 2009
@@ -1,0 +1,277 @@
+package Test::Fixme;
+
+use strict;
+use warnings;
+
+use Carp;
+use File::Finder;
+use File::Slurp;
+
+use Test::Builder;
+require Exporter;
+use vars qw( @ISA @EXPORT );
+ at ISA    = qw(Exporter);
+ at EXPORT = qw( run_tests );
+
+our $VERSION;
+$VERSION = '0.04';
+
+my $Test = Test::Builder->new;
+
+sub run_tests {
+
+    # Get the values and setup defaults if needed.
+    my %args = @_;
+    $args{match} = 'FIXME' unless defined $args{match} && length $args{match};
+    $args{where} = '.'     unless defined $args{where} && length $args{where};
+    $args{filename_match} = qr/./
+      unless defined $args{filename_match} && length $args{filename_match};
+
+    # Skip all tests if instructed to.
+    $Test->skip_all("All tests skipped.") if $args{skip_all};
+
+    # Get files to work with and set the plan.
+    my @files = list_files( $args{where}, $args{filename_match} );
+    $Test->plan( tests => scalar @files );
+
+    # Check ech file in turn.
+    foreach my $file (@files) {
+        my $results = scan_file( file => $file, match => $args{match} );
+
+        if ( scalar @$results == 0 ) {
+            $Test->ok( 1, "'$file'" );
+            next;
+        }
+        else {
+            $Test->ok( 0, "'$file'" );
+            $Test->diag( format_file_results($results) );
+        }
+    }
+}
+
+sub scan_file {
+    my %args = @_;
+    return undef unless $args{file} && $args{match};
+
+    # Get the contents of the files and split content into lines.
+    my $content     = load_file( $args{file} );
+    my @lines       = split $/, $content;
+    my $line_number = 0;
+
+    # Set up return array.
+    my @results = ();
+
+    foreach my $line (@lines) {
+        $line_number++;
+        next unless $line =~ m/$args{match}/;
+
+        # We have a match - add it to array.
+        push @results,
+          {
+            file  => $args{file},
+            match => $args{match},
+            line  => $line_number,
+            text  => $line,
+          };
+    }
+
+    return \@results;
+}
+
+sub format_file_results {
+    my $results = shift;
+    return undef unless defined $results;
+
+    my $out = '';
+
+    # format the file name.
+    $out .= "File: '" . ${$results}[0]->{file} . "'\n";
+
+    # format the results.
+    foreach my $result (@$results) {
+        my $line = $$result{line};
+        my $txt  = "    $line";
+        $txt .= ' ' x ( 8 - length $line );
+        $txt .= $$result{text} . "\n";
+        $out .= $txt;
+    }
+
+    return $out;
+}
+
+sub list_files {
+    my $path_arg = shift;
+    croak
+'You must specify a single directory, or reference to a list of directories'
+      unless defined $path_arg;
+
+    my $filename_match = shift;
+    if ( !defined $filename_match ) {
+
+        # Filename match defaults to matching any single character, for
+        # backwards compatibility with one-arg list_files() invocation
+        $filename_match = qr/./;
+    }
+
+    my @paths;
+    if ( ref $path_arg eq 'ARRAY' ) {
+
+        # Ref to array
+        @paths = @{$path_arg};
+    }
+    elsif ( ref $path_arg eq '' ) {
+
+        # one path
+        @paths = ($path_arg);
+    }
+    else {
+
+        # something else
+        croak
+'Argument to list_files must be a single path, or a reference to an array of paths';
+    }
+
+    my @files = ();
+
+    foreach my $path (@paths) {
+
+        # Die if we got a bad dir.
+        croak "The directory '$path' does not exist" unless -d $path;
+        push @files, File::Finder->type('f')->in($path);
+    }
+
+    # Find files using File::Finder.
+    @files =
+      sort    # sort the files
+      grep { m/$filename_match/ }
+      grep { !-l $_ }               # no symbolic links
+      grep { !m{.svn} }             # no Subversion directory contents
+      grep { !m{CVS/} }             # no CVS directory contents
+      @files;
+
+    return @files;
+}
+
+sub load_file {
+    my $filename = shift;
+
+    # If the file is not regular then return undef.
+    return undef unless -f $filename;
+
+    # Slurp the file.
+    my $content = read_file($filename);
+    return $content;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+ 
+Test::Fixme - check code for FIXMEs.
+ 
+=head1 SYNOPSIS
+ 
+    # In a test script like 't/test-fixme.t'
+    use Test::Fixme;
+    run_tests();
+
+    # You can also tailor the behaviour.
+    use Test::Fixme;
+    run_tests( where    => 'lib',      # where to find files to check
+               match    => 'TODO',     # what to check for
+               skip_all => $ENV{SKIP}  # should all tests be skipped
+    );
+
+=head1 DESCRIPTION
+ 
+When coding it is common to come up against problems that need to be
+addressed but that are not a big deal at the moment. What generally
+happens is that the coder adds comments like:
+
+ # FIXME - what about windows that are bigger than the screen?
+
+ # FIXME - add checking of user priviledges here.
+
+L<Test::Fixme> allows you to add a test file that ensures that none of
+these get forgotten in the module.
+
+=head2 Arguments
+
+By default run_tests will search for 'FIXME' in all the files it can
+find in the project. You can change these defaults by using 'where' or
+'match' as follows:
+
+    run_tests( where => 'lib', # just check the modules.
+               match => 'TODO' # look for things that are not done yet.
+    );
+
+=over 4
+
+=item where
+
+Specifies where to search for files.  This can be a scalar containing a
+single directory name, or it can be a listref containing multiple
+directory names.
+
+=item match
+
+Expression to search for within the files.  This may be a simple
+string, or a qr//-quoted regular expression.  For example:
+
+    match => qr/[T]ODO|[F]IXME|[B]UG/,
+
+=item filename_match
+
+Expression to filter file names.  This should be a qr//-quoted regular
+expression.  For example:
+
+    match => qr/\.(:pm|pl)$/,
+
+would only match .pm and .pl files under your specified directory.
+
+=back
+
+=head1 HINTS
+
+If you want to match something other than 'FIXME' then you may find
+that the test file itself is being caught. Try doing this:
+
+    run_tests( match => 'TO'.'DO' );
+
+You may also wish to suppress the tests - try this:
+
+    use Test::Fixme;
+    run_tests( skip_all => $ENV{SKIP_TEST_FIXME} );
+
+You can only run run_tests once per file. Please use several test
+files if you want to run several different tests.
+
+=head1 SEE ALSO
+
+L<Devel::FIXME>
+
+=head1 AUTHOR
+ 
+Edmund von der Burg E<lt>evdb at ecclestoad.co.ukE<gt>
+
+Please let me know if you have any comments or suggestions.
+
+L<http://ecclestoad.co.uk/>
+
+=head1 ACKNOWLEDGMENTS
+
+Dave O'Neill added support for 'filename_match' and also being able to pass a
+list of several directories in the 'where' argument. Many thanks.
+
+=head1 LICENSE
+
+Copryight (C) 2008 Edmund von der Burg C<<evdb at ecclestoad.co.uk>>
+
+This library is free software . You can redistribute it and/or modify it under
+the same terms as perl itself.
+
+=cut
+
+1;

Added: branches/upstream/libtest-fixme-perl/current/t/check_project.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/check_project.t?rev=32179&op=file
==============================================================================
--- branches/upstream/libtest-fixme-perl/current/t/check_project.t (added)
+++ branches/upstream/libtest-fixme-perl/current/t/check_project.t Wed Mar 18 03:14:18 2009
@@ -1,0 +1,5 @@
+use strict;
+use warnings;
+
+use Test::Fixme;
+run_tests( match => 'B' . 'UG' );

Added: branches/upstream/libtest-fixme-perl/current/t/dirs/deep/deep_a.txt
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/dirs/deep/deep_a.txt?rev=32179&op=file
==============================================================================
    (empty)

Added: branches/upstream/libtest-fixme-perl/current/t/dirs/deep/deep_b.txt
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/dirs/deep/deep_b.txt?rev=32179&op=file
==============================================================================
    (empty)

Added: branches/upstream/libtest-fixme-perl/current/t/dirs/deep/one/deep_one_a.txt
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/dirs/deep/one/deep_one_a.txt?rev=32179&op=file
==============================================================================
    (empty)

Added: branches/upstream/libtest-fixme-perl/current/t/dirs/deep/one/deep_one_b.txt
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/dirs/deep/one/deep_one_b.txt?rev=32179&op=file
==============================================================================
    (empty)

Added: branches/upstream/libtest-fixme-perl/current/t/dirs/deep/two/deep_two_a.txt
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/dirs/deep/two/deep_two_a.txt?rev=32179&op=file
==============================================================================
    (empty)

Added: branches/upstream/libtest-fixme-perl/current/t/dirs/deep/two/deep_two_b.txt
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/dirs/deep/two/deep_two_b.txt?rev=32179&op=file
==============================================================================
    (empty)

Added: branches/upstream/libtest-fixme-perl/current/t/dirs/normal/four.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/dirs/normal/four.pod?rev=32179&op=file
==============================================================================
    (empty)

Added: branches/upstream/libtest-fixme-perl/current/t/dirs/normal/one.txt
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/dirs/normal/one.txt?rev=32179&op=file
==============================================================================
--- branches/upstream/libtest-fixme-perl/current/t/dirs/normal/one.txt (added)
+++ branches/upstream/libtest-fixme-perl/current/t/dirs/normal/one.txt Wed Mar 18 03:14:18 2009
@@ -1,0 +1,7 @@
+abcdef
+ghijkl
+mnopqr
+stuvwx
+
+12345
+67890

Added: branches/upstream/libtest-fixme-perl/current/t/dirs/normal/three.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/dirs/normal/three.pm?rev=32179&op=file
==============================================================================
    (empty)

Added: branches/upstream/libtest-fixme-perl/current/t/dirs/normal/two.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/dirs/normal/two.pl?rev=32179&op=file
==============================================================================
--- branches/upstream/libtest-fixme-perl/current/t/dirs/normal/two.pl (added)
+++ branches/upstream/libtest-fixme-perl/current/t/dirs/normal/two.pl Wed Mar 18 03:14:18 2009
@@ -1,0 +1,12 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+# FIXME - this is bad (line 6).
+
+# TEST - test 1 (line 8).
+
+# TEST - test 2 (line 10).
+
+# Test - bogus test (line 12).

Added: branches/upstream/libtest-fixme-perl/current/t/dirs/types/normal.txt
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/dirs/types/normal.txt?rev=32179&op=file
==============================================================================
    (empty)

Added: branches/upstream/libtest-fixme-perl/current/t/format_results.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/format_results.t?rev=32179&op=file
==============================================================================
--- branches/upstream/libtest-fixme-perl/current/t/format_results.t (added)
+++ branches/upstream/libtest-fixme-perl/current/t/format_results.t Wed Mar 18 03:14:18 2009
@@ -1,0 +1,22 @@
+use strict;
+use warnings;
+
+use Test::More tests => 3;
+
+# Load the module.
+use_ok 'Test::Fixme';
+
+# Check the formating of results.
+my $results = Test::Fixme::scan_file(
+    file  => 't/dirs/normal/two.pl',
+    match => 'TEST'
+);
+ok $results, "got results to work with";
+
+my $expected = << 'STOP';
+File: 't/dirs/normal/two.pl'
+    8       # TEST - test 1 (line 8).
+    10      # TEST - test 2 (line 10).
+STOP
+
+is Test::Fixme::format_file_results($results), $expected, "check formatting";

Added: branches/upstream/libtest-fixme-perl/current/t/list_files.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/list_files.t?rev=32179&op=file
==============================================================================
--- branches/upstream/libtest-fixme-perl/current/t/list_files.t (added)
+++ branches/upstream/libtest-fixme-perl/current/t/list_files.t Wed Mar 18 03:14:18 2009
@@ -1,0 +1,80 @@
+use strict;
+use warnings;
+
+use Test::More tests => 13;
+
+# Load the module.
+use_ok 'Test::Fixme';
+
+{    # Check that listing a directory that does not exist dies.
+    local $SIG{__WARN__} = sub { 1 };
+    eval { my @files = Test::Fixme::list_files('t/i/do/not/exist'); };
+    ok $@, 'list_files died';
+    ok $@ =~ m:^The directory 't/i/do/not/exist' does not exist:,
+      "check that non-existent directory causes 'die'";
+}
+
+{    # Test that sub croaks unless a path is passed.
+    local $SIG{__WARN__} = sub { 1 };
+    eval { my @files = Test::Fixme::list_files(); };
+    ok $@, 'list_files died';
+    like $@,
+qr{^You must specify a single directory, or reference to a list of directories},
+      "check that no directory causes 'die'";
+}
+
+{    # Test the list_files function.
+    my $dir    = 't/dirs/normal';
+    my @files  = Test::Fixme::list_files($dir);
+    my @wanted = sort map { "$dir/$_" } qw( one.txt two.pl three.pm four.pod );
+    is_deeply( \@files, \@wanted, "check correct files returned from '$dir'" );
+}
+
+{    # Check that the search descends into sub folders.
+    my $dir    = 't/dirs/deep';
+    my @files  = Test::Fixme::list_files($dir);
+    my @wanted = sort map { "$dir/$_" }
+      map { "$_.txt" }
+      qw'deep_a deep_b
+      one/deep_one_a one/deep_one_b
+      two/deep_two_a two/deep_two_b';
+    is_deeply( \@files, \@wanted, "check correct files returned from '$dir'" );
+}
+
+{    # Check that we can scan a reference to a list of dirnames
+    my @dirs  = qw( t/dirs/normal t/dirs/deep/one );
+    my @files = Test::Fixme::list_files( \@dirs );
+    my @wanted =
+      sort qw(t/dirs/deep/one/deep_one_a.txt t/dirs/deep/one/deep_one_b.txt ),
+      map { "t/dirs/normal/$_" } qw( one.txt two.pl three.pm four.pod );
+    is_deeply( \@files, \@wanted,
+        "check correct files returned from " . join( ', ', @dirs ) );
+}
+
+{    # Test the list_files function with a filename_match regex
+    my $dir    = 't/dirs/normal';
+    my @files  = Test::Fixme::list_files( $dir, qr/\.(?:pl|pm)$/ );
+    my @wanted = sort map { "$dir/$_" } qw( two.pl three.pm );
+    is_deeply( \@files, \@wanted, "check correct files returned from '$dir'" );
+}
+
+SKIP: {    # Check that non files do not get returned.
+    skip( "cannot create symlink", 4 ) unless eval { symlink( "", "" ); 1 };
+
+    my $dir         = "t/dirs/types";
+    my $target      = "normal.txt";
+    my $target_file = "$dir/$target";
+    my $symlink     = "$dir/symlink";
+
+    # Make a symbolic link
+    ok symlink( $target, $symlink ), "create symlinked file";
+    ok -e $symlink, "symlink now exists";
+
+    my @files  = Test::Fixme::list_files($dir);
+    my @wanted = ($target_file);
+
+    is_deeply( \@files, \@wanted,
+        "check that non files are not returned from '$dir'" );
+
+    ok unlink($symlink), "delete symlinked file";
+}

Added: branches/upstream/libtest-fixme-perl/current/t/load_file.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/load_file.t?rev=32179&op=file
==============================================================================
--- branches/upstream/libtest-fixme-perl/current/t/load_file.t (added)
+++ branches/upstream/libtest-fixme-perl/current/t/load_file.t Wed Mar 18 03:14:18 2009
@@ -1,0 +1,23 @@
+use strict;
+use warnings;
+
+use Test::More tests => 4;
+
+# Load the module.
+use_ok 'Test::Fixme';
+
+{    # Test loading of simple file.
+    my $content  = Test::Fixme::load_file('t/dirs/normal/one.txt');
+    my $expected = "abcdef\nghijkl\nmnopqr\nstuvwx\n\n12345\n67890\n";
+    is $content, $expected, "check simple file";
+}
+
+{    # Test loading of non-existent file.
+    ok !defined Test::Fixme::load_file('t/i/do/not/exist'),
+      "load non-existent file";
+}
+
+{    # Test loading of a zero length file
+    is Test::Fixme::load_file('t/dirs/normal/four.pod'), '',
+      "load zero length file";
+}

Added: branches/upstream/libtest-fixme-perl/current/t/scan_file.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/scan_file.t?rev=32179&op=file
==============================================================================
--- branches/upstream/libtest-fixme-perl/current/t/scan_file.t (added)
+++ branches/upstream/libtest-fixme-perl/current/t/scan_file.t Wed Mar 18 03:14:18 2009
@@ -1,0 +1,65 @@
+use strict;
+use warnings;
+
+use Test::More tests => 7;
+
+# Load the module.
+use_ok 'Test::Fixme';
+
+{    # Check that bad input is not accepted.
+    ok !defined Test::Fixme::scan_file(), "no input";
+    ok !defined Test::Fixme::scan_file( match => 'TEST' ), "no match";
+    ok !defined Test::Fixme::scan_file( file => 't/dirs/normal/one.txt' ),
+      "no file";
+
+}
+
+{    # Scan an empty file to get an empty arrayref.
+    my $arrayref = Test::Fixme::scan_file(
+        file  => 't/dirs/normal/four.pod',
+        match => 'TEST'
+    );
+    ok eq_array( $arrayref, [] ), "empty file, empty array";
+}
+
+{    # Scan a file where there should be one hit.
+    my $arrayref = Test::Fixme::scan_file(
+        file  => 't/dirs/normal/one.txt',
+        match => 'ijk'
+    );
+
+    my $expected = [
+        {
+            line  => 2,
+            text  => "ghijkl",
+            file  => 't/dirs/normal/one.txt',
+            match => 'ijk'
+        }
+    ];
+
+    ok eq_array( $arrayref, $expected ), "find one result";
+}
+
+{    # scan file that should have several hits.
+    my $arrayref = Test::Fixme::scan_file(
+        file  => 't/dirs/normal/two.pl',
+        match => 'TEST'
+    );
+
+    my $expected = [
+        {
+            match => 'TEST',
+            file  => 't/dirs/normal/two.pl',
+            line  => 8,
+            text  => "# TEST - test 1 (line 8)."
+        },
+        {
+            match => 'TEST',
+            file  => 't/dirs/normal/two.pl',
+            line  => 10,
+            text  => "# TEST - test 2 (line 10)."
+        },
+    ];
+
+    ok eq_array( $arrayref, $expected ), "find two results";
+}

Added: branches/upstream/libtest-fixme-perl/current/t/skip_all.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/skip_all.t?rev=32179&op=file
==============================================================================
--- branches/upstream/libtest-fixme-perl/current/t/skip_all.t (added)
+++ branches/upstream/libtest-fixme-perl/current/t/skip_all.t Wed Mar 18 03:14:18 2009
@@ -1,0 +1,2 @@
+use Test::Fixme;
+run_tests( skip_all => 1 );

Added: branches/upstream/libtest-fixme-perl/current/t/test-fixme.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-fixme-perl/current/t/test-fixme.t?rev=32179&op=file
==============================================================================
--- branches/upstream/libtest-fixme-perl/current/t/test-fixme.t (added)
+++ branches/upstream/libtest-fixme-perl/current/t/test-fixme.t Wed Mar 18 03:14:18 2009
@@ -1,0 +1,11 @@
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+
+# Load the module.
+use_ok 'Test::Fixme';
+
+# Check we have a version.
+ok $Test::Fixme::VERSION, "check we have a version number";
+




More information about the Pkg-perl-cvs-commits mailing list