Test-AutoLoader-0.03/0040755016666600000240000000000010270106550013412 5ustar bwarfcdromTest-AutoLoader-0.03/tlib/0040755016666600000240000000000010270106550014344 5ustar bwarfcdromTest-AutoLoader-0.03/tlib/TestBusted1.pm0100644016666600000240000000006310265547037017062 0ustar bwarfcdrompackage TestBusted1; use AutoLoader 'AUTOLOAD'; 1; Test-AutoLoader-0.03/tlib/auto/0040755016666600000240000000000010270106550015314 5ustar bwarfcdromTest-AutoLoader-0.03/tlib/auto/TestBusted2/0040755016666600000240000000000010270106550017464 5ustar bwarfcdromTest-AutoLoader-0.03/tlib/auto/TestBusted2/no_ready.al0100755016666600000240000000007110267014627021611 0ustar bwarfcdrom"Peek-a-boo, I can't see you: everything must be grand"; Test-AutoLoader-0.03/tlib/auto/TestBusted2/autosplit.ix0100644016666600000240000000000310265547725022061 0ustar bwarfcdrom1; Test-AutoLoader-0.03/tlib/auto/TestBusted2/empty.al0100644016666600000240000000000010267015125021126 0ustar bwarfcdromTest-AutoLoader-0.03/tlib/auto/TestBusted2/no_worky.al0100644016666600000240000000002510265547733021663 0ustar bwarfcdrom'simple way to break Test-AutoLoader-0.03/tlib/auto/EmptyModule/0040755016666600000240000000000010270106550017560 5ustar bwarfcdromTest-AutoLoader-0.03/tlib/auto/EmptyModule/autosplit.ix0100644016666600000240000000000310267470360022145 0ustar bwarfcdrom1; Test-AutoLoader-0.03/tlib/auto/TestBusted1/0040755016666600000240000000000010270106550017463 5ustar bwarfcdromTest-AutoLoader-0.03/tlib/auto/TestBusted1/autosplit.ix0100644016666600000240000000000310265547242022052 0ustar bwarfcdrom1; Test-AutoLoader-0.03/tlib/auto/TestBusted1/ostrich.al0100644016666600000240000000011710267002143021447 0ustar bwarfcdrom"Peek-a-bee, you can't see me, as long as I've got me head in the sand..."; 1; Test-AutoLoader-0.03/tlib/TestBusted2.pm0100644016666600000240000000006310265550041017050 0ustar bwarfcdrompackage TestBusted2; use AutoLoader 'AUTOLOAD'; 1; Test-AutoLoader-0.03/tlib/EmptyModule.pm0100644016666600000240000000006310267470333017153 0ustar bwarfcdrompackage EmptyModule; use AutoLoader 'AUTOLOAD'; 1; Test-AutoLoader-0.03/README0100644016666600000240000000216610270106513014273 0ustar bwarfcdromTest/AutoLoader version 0.03 ============================ DESCRIPTION This single-purpose module attempts to eliminate uncaught syntax errors or other obvious goofs in subroutines that are autosplit, and hence not looked at by C. Ideally, this module will become unnecessary as you reach full coverage of those subroutines in your unit tests. Until that happy day, however, this should provide a quick and dirty backstop for embarrassing typos. Test::AutoLoader is built on Test::Builder, and should interoperate smoothly with other such modules (e.g. Test::Simple, Test::More). INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES To run tests using this module, you will need: Test::Builder File::Spec To run the tests *on* this module, you will need: Test::More Test::Tester (optional, but required for the real tests) Test::Pod (optional) COPYRIGHT AND LICENSE This module and its accompanying files are distributed under the GNU General Public License. Copyright (C) 2005 Neurogen Corporation, Branford, CT, USA. Test-AutoLoader-0.03/MANIFEST0100644016666600000240000000056010267501003014537 0ustar bwarfcdromAutoLoader.pm Changes MANIFEST META.yml Makefile.PL README t/00basic.t tlib/EmptyModule.pm tlib/TestBusted1.pm tlib/TestBusted2.pm tlib/auto/EmptyModule/autosplit.ix tlib/auto/TestBusted1/autosplit.ix tlib/auto/TestBusted1/ostrich.al tlib/auto/TestBusted2/autosplit.ix tlib/auto/TestBusted2/empty.al tlib/auto/TestBusted2/no_ready.al tlib/auto/TestBusted2/no_worky.al Test-AutoLoader-0.03/META.yml0100644016666600000240000000026510270104117014660 0ustar bwarfcdrom--- name: Test-AutoLoader version: 0.03 license: gpl requires: File::Spec: 0 Test::Builder: 0 build_requires: Test::Pod: 0.95 Test::Tester: 0.08 no_index: dir: - tlib Test-AutoLoader-0.03/Changes0100644016666600000240000000046510270104727014713 0ustar bwarfcdromRevision history for Perl extension Test::AutoLoader. 0.03 Fri Jul 22 01:53:00 2005 - Fixed minor problems with Makefile.PL and META.yml 0.02 Wed Jul 20 12:58:23 2005 - Initial CPAN release 0.01 Wed Jul 13 19:27:07 2005 - original version; created by h2xs 1.21 with options -XAn Test::AutoLoader Test-AutoLoader-0.03/Makefile.PL0100644016666600000240000000076110270104240015357 0ustar bwarfcdromuse ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'Test::AutoLoader', 'VERSION_FROM' => 'AutoLoader.pm', # finds $VERSION 'PREREQ_PM' => {Test::Builder=>0}, ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'AutoLoader.pm', # retrieve abstract from module AUTHOR => 'Ben Warfield ') : ()), ); Test-AutoLoader-0.03/t/0040755016666600000240000000000010270106550013655 5ustar bwarfcdromTest-AutoLoader-0.03/t/00basic.t0100644016666600000240000000512510270105305015260 0ustar bwarfcdrom#!/usr/local/bin/perl my ($NO_TEST_TESTER,$NO_TEST_POD); BEGIN { eval "use Test::Tester 0.08;"; $NO_TEST_TESTER = $@; eval "use Test::Pod 0.95"; $NO_TEST_POD = $@; } use Test::More tests=>54; use POSIX; use strict; use_ok("Test::AutoLoader"); can_ok("Test::AutoLoader",'autoload_ok'); SKIP: { skip "Pod test requires Test::Pod 0.95",1 if $NO_TEST_POD; pod_file_ok("AutoLoader.pm"); } if ($NO_TEST_TESTER) { SKIP:{ skip "Remaining tests require Test::Tester 0.08", 51} exit(0); } require File::Spec; # test setup: unshift @INC, 'tlib'; require TestBusted1; require TestBusted2; require EmptyModule; my @unreadable = (File::Spec->catdir(qw(tlib auto TestBusted1)), File::Spec->catfile(qw(tlib auto TestBusted2 no_ready.al))); my $CAN_CHMOD = chmod 0000, @unreadable; my $file_errors; $file_errors .=<1,name=>"Autoload of POSIX (all files)"},"Standard-distribution module, all files"], [ [qw(POSIX strcpy)],{ok=>1,name=>"Autoload of POSIX (listed subroutines)"},"Standard-distribution module, one file"], [ [qw(POSIX no_such_function)], {ok=>0,diag=>" couldn't load no_such_function.al: No such file or directory"}, "Standard-distribution, bad subroutine name"], [ [qw(strict)], {ok=>0,diag=>"Unable to find valid autoload directory for strict"}, "Non-existent auto directory"], [ [qw(EmptyModule)], {ok=>0,diag=>"No autoloaded files found"}, "No files in auto directory"], [ [qw(Foo::Bar::Baz)], {ok=>0,diag=>"Unable to find valid autoload directory for Foo::Bar::Baz (perhaps you forgot to load 'Foo::Bar::Baz'?)"}, "Module not loaded"], [ [qw(TestBusted2 no_worky)], {ok=>0,diag=>" couldn't load no_worky.al: Compile error"}, "Syntax error"], [ [qw(TestBusted2 no_ready nobody_home empty)], {ok=>0,diag=>$file_errors}, "File-reading errors"], [ [qw()], {ok=>0,diag=>"",name=>"Can't test autoload of empty package"}, "Empty arglist"], # [ [qw()], {ok=>0,diag=>""}, "name"], ); if ($CAN_CHMOD) { push @tests, [ [qw(TestBusted1)], {ok=>0,diag=>"Unable to find valid autoload directory for TestBusted1"}, "Unreadable auto directory"], } foreach my $test (@tests) { check_test( sub {autoload_ok(@{$test->[0]})},$test->[1],$test->[2]) } if ($CAN_CHMOD) { chmod 0755, @unreadable or warn "Couldn't chmod @unreadable back: $!\n"; } else { SKIP:{skip "Couldn't set up unreadable directory for test",5} } Test-AutoLoader-0.03/AutoLoader.pm0100644016666600000240000001152410270104270016004 0ustar bwarfcdrom# (c) Copyright 2005 Neurogen Corporation, all rights reserved. package Test::AutoLoader; use 5.006; # for 'warnings' use strict; use warnings; use Exporter; BEGIN{*import = \&Exporter::import}; use File::Spec; use Test::Builder; our @EXPORT = ('autoload_ok'); our $VERSION = 0.03; # Lifted fairly directly from AutoLoader.pm my ($is_dosish, $is_epoc,$is_vms, $is_macos); BEGIN { $is_dosish = $^O eq 'dos' || $^O eq 'os2' || $^O eq 'MSWin32'; $is_epoc = $^O eq 'epoc'; $is_vms = $^O eq 'VMS'; $is_macos = $^O eq 'MacOS'; } sub autoload_ok { my ($package,@subnames) = @_; my $Test = Test::Builder->new; # initialize the special vars here? (if we make this part of Test::More) unless ($package) { return $Test->ok(0,"Can't test autoload of empty package") } my $test_label = "Autoload of $package" . (@subnames ? " (listed subroutines)" : " (all files)"); (my $pkg = $package) =~ s#::#/#g; my $dirname; my (@ok,@nok); if (defined($dirname = $INC{"$pkg.pm"})) { if ($is_macos) { $pkg =~ tr#/#:#; $dirname =~ s#^(.*)$pkg\.pm\z#$1auto:$pkg#s; } else { $dirname =~ s#^(.*)$pkg\.pm\z#$1auto/$pkg#s; } } unless (defined $dirname and -d $dirname && -r _ ) { $Test->ok(0,$test_label); my $diag = "Unable to find valid autoload directory for $package"; $diag .= " (perhaps you forgot to load '$package'?)" if !defined $dirname; $Test->diag($diag); return; } my @filenames = map "$_.al", @subnames; if (!@filenames ) { unless (opendir AUTOLOAD, $dirname) { $Test->ok(0,$test_label); $Test->diag("Can't open $dirname: $!"); return; } @filenames = grep /.+\.al\z/, readdir AUTOLOAD; closedir AUTOLOAD or $Test->diag("Unable to close $dirname: $!"); } foreach my $filename (@filenames) { my $full_path = File::Spec->catfile($dirname,$filename); # also lifted directly from AutoLoader.pm, then tweaked unless ($full_path =~ m|^/|s) { if ($is_dosish && $full_path !~ m{^([a-z]:)?[\\/]}is) { $full_path = "./$full_path"; } elsif ($is_epoc && $full_path !~ m{^([a-z?]:)?[\\/]}is) { $full_path = "./$full_path"; } elsif ($is_vms) { # XXX todo by VMSmiths $full_path = "./$full_path"; } elsif (!$is_macos) { $full_path = "./$full_path"; } } local ($@,$!,$?); if (my $ret = do $full_path) { push @ok, $filename; } else { my $err = $! || $@ && "Compile error" || "false return value"; push @nok, [$filename,$err]; } } if (@nok) { $Test->ok(0,$test_label); $Test->diag(map " couldn't load $_->[0]: $_->[1]\n", @nok); return 0; } elsif(@ok) { return $Test->ok(1,$test_label); } else { $Test->ok(0,$test_label); $Test->diag("No autoloaded files found"); return 0; } } no warnings 'void'; "I pass the test. I will diminish, and go into the West, and remain Galadriel" __END__ =head1 NAME Test::AutoLoader - a testing utility for autosplit/autoloaded modules. =head1 SYNOPSIS use Test::AutoLoader; use Test::More tests => 3; use_ok("My::Module"); # from Test::More autoload_ok("My::Module","mysub","sub_two); # test only the listed subs autoload_ok("My::Module"); # tests all '.al' files found for the module =head1 DESCRIPTION This single-purpose module attempts to eliminate uncaught syntax errors or other obvious goofs in subroutines that are autosplit, and hence not looked at by C. Ideally, this module will become unnecessary as you reach full coverage of those subroutines in your unit tests. Until that happy day, however, this should provide a quick and dirty backstop for embarrassing typos. Test::AutoLoader is built on Test::Builder, and should interoperate smoothly with other such modules (e.g. Test::Simple, Test::More). =head1 EXPORT =head2 autoload_ok Very much like the 'use_ok' subroutine (see L). If passed only a module name, it will find all subroutine definitions in the "auto" directory and attempt to compile them. If passed a list of subroutine names, it will look for and attempt to compile those (and only those). Any files that cannot be found (if specified directly), read, and compiled will be listed in the diagnostic output for the failed test. =head1 AUTHOR Ben Warfield (ben_warfield@nrgn.com) =head1 COPYRIGHT AND LICENSE This module is copyright (c) 2005 Neurogen Corporation, Branford, Connecticut, USA. It may be distributed under the terms of the GNU General Public License. =head1 SEE ALSO L, L, L. =cut