| 1 | #!/usr/bin/env perl |
| 2 | |
| 3 | use strict; |
| 4 | use warnings; |
| 5 | |
| 6 | use File::Basename; |
| 7 | use File::Spec; |
| 8 | use Test::More; |
| 9 | use Test::CheckManifest; |
| 10 | |
| 11 | use Cwd; |
| 12 | |
| 13 | local $ENV{NO_MANIFEST_CHECK} = 1; |
| 14 | |
| 15 | my $sub = Test::CheckManifest->can('_check_manifest'); |
| 16 | ok $sub; |
| 17 | |
| 18 | my $dir = Cwd::realpath( dirname __FILE__ ); |
| 19 | $dir =~ s{.t\z}{}; |
| 20 | my $t_dir = File::Spec->catdir( $dir, 't' ); |
| 21 | my $abs_t_file = File::Spec->rel2abs( __FILE__ ); |
| 22 | |
| 23 | # my ($existing_files, $manifest_files, $excluded, $msg) = @_; |
| 24 | |
| 25 | my $diag = ''; |
| 26 | { |
| 27 | no warnings 'redefine'; |
| 28 | sub Test::Builder::diag { |
| 29 | $diag .= $_[1] . "\n"; |
| 30 | }; |
| 31 | } |
| 32 | |
| 33 | my $cnt = 0; |
| 34 | |
| 35 | { |
| 36 | my @tests = ( |
| 37 | [ undef, undef, undef, 'test', 1 ], |
| 38 | [ ['/t/test'], undef, undef, 'test', '' ], |
| 39 | [ ['/t/test'], ['/t/test'], undef, 'test', 1 ], |
| 40 | [ ['/t/test'], undef, {'/t/test' => 1}, 'test', 1 ], |
| 41 | [ ['/t/test'], ['/test'], {'/t/test' => 1}, 'test', '' ], |
| 42 | [ ['/t/test'], ['/t/test', '/t/test'], undef, 'test', '' ], |
| 43 | [ ['/t/test','/t/test2'], ['/t/test'], undef, 'test', '' ], |
| 44 | ); |
| 45 | |
| 46 | for my $test ( @tests ) { |
| 47 | $diag = ''; |
| 48 | |
| 49 | my @params = @{$test}; |
| 50 | my $expected = pop @params; |
| 51 | |
| 52 | my $result = $sub->( @params, 'No Manifest' ); |
| 53 | |
| 54 | is $result, $expected, "Test $cnt"; |
| 55 | |
| 56 | $cnt++; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | { |
| 61 | local $Test::CheckManifest::test_bool = 0; |
| 62 | my @tests = ( |
| 63 | [ undef, undef, undef, 'test', '' ], |
| 64 | [ ['/t/test'], undef, undef, 'test', 1 ], |
| 65 | [ ['/t/test'], ['/t/test'], undef, 'test', '' ], |
| 66 | [ ['/t/test'], undef, {'/t/test' => 1}, 'test', '' ], |
| 67 | [ ['/t/test'], ['/test'], {'/t/test' => 1}, 'test', 1 ], |
| 68 | [ ['/t/test'], ['/t/test', '/t/test'], undef, 'test', 1 ], |
| 69 | [ ['/t/test','/t/test2'], ['/t/test'], undef, 'test', 1 ], |
| 70 | ); |
| 71 | |
| 72 | for my $test ( @tests ) { |
| 73 | $diag = ''; |
| 74 | |
| 75 | my @params = @{$test}; |
| 76 | my $expected = pop @params; |
| 77 | |
| 78 | my $result = $sub->( @params, 'No Manifest' ); |
| 79 | |
| 80 | is $result, $expected; |
| 81 | $cnt++; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | { |
| 86 | local $Test::CheckManifest::test_bool = 0; |
| 87 | local $Test::CheckManifest::VERBOSE = 0; |
| 88 | my @tests = ( |
| 89 | [ undef, undef, undef, 'test', '' ], |
| 90 | [ ['/t/test'], undef, undef, 'test', 1 ], |
| 91 | [ ['/t/test'], ['/t/test'], undef, 'test', '' ], |
| 92 | [ ['/t/test'], undef, {'/t/test' => 1}, 'test', '' ], |
| 93 | [ ['/t/test'], ['/test'], {'/t/test' => 1}, 'test', 1 ], |
| 94 | [ ['/t/test'], ['/t/test', '/t/test'], undef, 'test', 1 ], |
| 95 | [ ['/t/test','/t/test2'], ['/t/test'], undef, 'test', 1 ], |
| 96 | ); |
| 97 | |
| 98 | for my $test ( @tests ) { |
| 99 | $diag = ''; |
| 100 | |
| 101 | my @params = @{$test}; |
| 102 | my $expected = pop @params; |
| 103 | |
| 104 | my $result = $sub->( @params, 'No Manifest' ); |
| 105 | |
| 106 | is $result, $expected; |
| 107 | |
| 108 | $cnt++; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | { |
| 113 | local $Test::CheckManifest::VERBOSE = 0; |
| 114 | my @tests = ( |
| 115 | [ undef, undef, undef, 'test', 1 ], |
| 116 | [ ['/t/test'], undef, undef, 'test', '' ], |
| 117 | [ ['/t/test'], ['/t/test'], undef, 'test', 1 ], |
| 118 | [ ['/t/test'], undef, {'/t/test' => 1}, 'test', 1 ], |
| 119 | [ ['/t/test'], ['/test'], {'/t/test' => 1}, 'test', '' ], |
| 120 | [ ['/t/test'], ['/t/test', '/t/test'], undef, 'test', '' ], |
| 121 | [ ['/t/test','/t/test2'], ['/t/test'], undef, 'test', '' ], |
| 122 | ); |
| 123 | |
| 124 | for my $test ( @tests ) { |
| 125 | $diag = ''; |
| 126 | |
| 127 | my @params = @{$test}; |
| 128 | my $expected = pop @params; |
| 129 | |
| 130 | my $result = $sub->( @params, 'No Manifest' ); |
| 131 | |
| 132 | is $result, $expected; |
| 133 | |
| 134 | $cnt++; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | done_testing(); |