diff options
author | Yves Orton <demerphq@gmail.com> | 2023-03-18 22:31:56 +0100 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2023-03-22 02:53:47 +0800 |
commit | ca54131a969bed4c2fa42de7cb41620de2e9ea01 (patch) | |
tree | 7085bbff638fc0e0d0ad351ba0b4c8e3a9dac5ae /t/porting | |
parent | 03d84c69373359fcef54157b6459b1ce357daf09 (diff) | |
download | perl-ca54131a969bed4c2fa42de7cb41620de2e9ea01.tar.gz |
t/porting/test_testlist.t - test that we test the same thing with t/harness and t/TEST
Also that we test everything expected in MANIFEST.
Also includes some fixups to t/TEST to deal with the fact
that List/Util is not anymore the name of a distribution
even though it is the name of an extension. Same for Cwd.
Diffstat (limited to 't/porting')
-rw-r--r-- | t/porting/test_testlist.t | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/t/porting/test_testlist.t b/t/porting/test_testlist.t new file mode 100644 index 0000000000..6cebf4c6f2 --- /dev/null +++ b/t/porting/test_testlist.t @@ -0,0 +1,94 @@ +BEGIN { + chdir '..' if -d '../dist'; + push @INC, "lib"; + require './t/test.pl'; +} + +use strict; +use warnings; + +# Test that t/TEST and t/harness test the same files, and that all the +# test files (.t files) listed in MANIFEST are tested by both. +# +# We enabled the various special tests as this simplifies our MANIFEST +# parsing. In theory if someone adds a new test directory this should +# tell us if one of the files does not know about it. + +plan tests => 3; + +my (%th, %tt, %all); +$ENV{PERL_TORTURE_TEST} = 1; +$ENV{PERL_TEST_MEMORY} = 1; +$ENV{PERL_BENCHMARK} = 1; + +for my $file (`$^X t/harness -dumptests`) { + chomp $file; + $all{$file}++; + $th{$file}++; +} + +for my $file (`$^X t/TEST -dumptests`) { + chomp $file; + $all{$file}++; + delete $th{$file} or $tt{$file}++; +} + +is(0+keys(%th), 0, "t/harness will not test anything that t/TEST does not") + or print STDERR map { "# t/harness: $_\n" } sort keys %th; +is(0+keys(%tt), 0, "t/TEST will not test aything that t/harness does not") + or print STDERR map { "# tTEST: $_\n" } sort keys %tt; + +sub get_extensions { + my %extensions; + open my $ifh, "<", "config.sh" + or die "Failed to open 'config.sh': $!"; + while (<$ifh>) { + if (/^extensions='([^']+)'/) { + my $list = $1; + NAME: + foreach my $name (split /\s+/, $list) { + $name = "PathTools" if $name eq "Cwd"; + $name = "Scalar/List/Utils" if $name eq "List/Util"; + my $sub_dir = $name; + $sub_dir =~ s!/!-!g; + foreach my $dir (qw(cpan dist ext)) { + if (-e "$dir/$sub_dir") { + $extensions{"$dir/$sub_dir"} = $name; + next NAME; + } + } + die "Could not find '$name'\n"; + } + last; + } + } + close $ifh; + return \%extensions; +} + +sub find_in_manifest_but_missing { + my $extension = get_extensions(); + my %missing; + my $is_os2 = $^O eq "os2"; + my $is_win32 = $^O eq "MSWin32"; + open my $ifh, "<", "MANIFEST" + or die "Failed to open 'MANIFEST' for read: $!"; + while (<$ifh>) { + chomp; + my ($file, $descr) = split /\t+/, $_; + next if $file eq "t/test.pl" + or $file!~m!(?:\.t|/test\.pl)\z! + or (!$is_os2 and $file=~m!^(?:t/)?os2/!) + or (!$is_win32 and $file=~m!^(?:t/)?win32/!); + if ($file=~m!^(cpan|dist|ext/[^/]+)!) { + my $path = $1; + next unless $extension->{$path}; + } + $missing{$file}++ unless $all{$file}; + } + close $ifh; + return \%missing; +} +my $missing = find_in_manifest_but_missing(); +is(0+keys(%$missing), 0, "Nothing in manifest that we wouldn't test") + or print STDERR map { "# $_\n" } sort keys %$missing; |