1BEGIN { 2 chdir '..' if -d '../dist'; 3 push @INC, "lib"; 4 require './t/test.pl'; 5} 6 7use strict; 8use warnings; 9 10# Test that t/TEST and t/harness test the same files, and that all the 11# test files (.t files) listed in MANIFEST are tested by both. 12# 13# We enabled the various special tests as this simplifies our MANIFEST 14# parsing. In theory if someone adds a new test directory this should 15# tell us if one of the files does not know about it. 16 17plan tests => 3; 18 19my (%th, %tt, %all); 20$ENV{PERL_TORTURE_TEST} = 1; 21$ENV{PERL_TEST_MEMORY} = 1; 22$ENV{PERL_BENCHMARK} = 1; 23 24for my $file (`$^X t/harness -dumptests`) { 25 chomp $file; 26 $all{$file}++; 27 $th{$file}++; 28} 29 30for my $file (`$^X t/TEST -dumptests`) { 31 chomp $file; 32 $all{$file}++; 33 delete $th{$file} or $tt{$file}++; 34} 35 36is(0+keys(%th), 0, "t/harness will not test anything that t/TEST does not") 37 or print STDERR map { "# t/harness: $_\n" } sort keys %th; 38is(0+keys(%tt), 0, "t/TEST will not test anything that t/harness does not") 39 or print STDERR map { "# tTEST: $_\n" } sort keys %tt; 40 41sub get_extensions { 42 my %extensions; 43 open my $ifh, "<", "config.sh" 44 or die "Failed to open 'config.sh': $!"; 45 while (<$ifh>) { 46 if (/^extensions='([^']+)'/) { 47 my $list = $1; 48 NAME: 49 foreach my $name (split /\s+/, $list) { 50 $name = "PathTools" if $name eq "Cwd"; 51 $name = "Scalar/List/Utils" if $name eq "List/Util"; 52 my $sub_dir = $name; 53 $sub_dir =~ s!/!-!g unless $sub_dir =~ /^Encode/; 54 foreach my $dir (qw(cpan dist ext)) { 55 if (-e "$dir/$sub_dir") { 56 $extensions{"$dir/$sub_dir"} = $name; 57 next NAME; 58 } 59 } 60 die "Could not find '$name'\n"; 61 } 62 last; 63 } 64 } 65 close $ifh; 66 return \%extensions; 67} 68 69sub find_in_manifest_but_missing { 70 my $extension = get_extensions(); 71 my %missing; 72 my $is_os2 = $^O eq "os2"; 73 my $is_win32 = $^O eq "MSWin32"; 74 open my $ifh, "<", "MANIFEST" 75 or die "Failed to open 'MANIFEST' for read: $!"; 76 while (<$ifh>) { 77 chomp; 78 my ($file, $descr) = split /\t+/, $_; 79 next if $file eq "t/test.pl" 80 or $file!~m!(?:\.t|/test\.pl)\z! 81 or (!$is_os2 and $file=~m!^(?:t/)?os2/!) 82 or (!$is_win32 and $file=~m!^(?:t/)?win32/!); 83 if ($file=~m!^(cpan|dist|ext/[^/]+)!) { 84 my $path = $1; 85 next unless $extension->{$path}; 86 } 87 $missing{$file}++ unless $all{$file}; 88 } 89 close $ifh; 90 return \%missing; 91} 92my $missing = find_in_manifest_but_missing(); 93is(0+keys(%$missing), 0, "Nothing in manifest that we wouldn't test") 94 or print STDERR map { "# $_\n" } sort keys %$missing; 95