| 1 | package Test::PAUSE::ConsistentPermissions; | ||
| 2 | |||
| 3 | use strictures 2; | ||
| 4 | use Test::PAUSE::ConsistentPermissions::Check; | ||
| 5 | use parent 'Exporter'; | ||
| 6 | use Test::More; | ||
| 7 | use Parse::LocalDistribution; | ||
| 8 | |||
| 9 | our $VERSION = '0.003'; | ||
| 10 | |||
| 11 | our @EXPORT = (@Test::More::EXPORT, qw/all_permissions_consistent/); | ||
| 12 | |||
| 13 | sub all_permissions_consistent | ||
| 14 | { | ||
| 15 | my $authority_with = shift; | ||
| 16 | |||
| 17 | # FIXME: figure out default to use for Authority. | ||
| 18 | |||
| 19 | # FIXME: is RELEASE_TESTING the appropriate time for this?? | ||
| 20 | plan skip_all => 'Set RELEASE_TESTING environmental variable to test this.' unless $ENV{RELEASE_TESTING}; | ||
| 21 | |||
| 22 | my $provides = Parse::LocalDistribution->new->parse(); | ||
| 23 | my $checker = Test::PAUSE::ConsistentPermissions::Check->new(); | ||
| 24 | my $results = $checker->report_problems([keys %$provides], $authority_with); | ||
| 25 | my $notes = ''; | ||
| 26 | open my $nh, '>', \$notes; | ||
| 27 | $checker->module_info_to_fh($results, $nh); | ||
| 28 | close($nh); | ||
| 29 | note($notes); | ||
| 30 | if(@{$results->{problems}}) | ||
| 31 | { | ||
| 32 | my $problems = ''; | ||
| 33 | open my $ph, '>', \$problems; | ||
| 34 | $checker->problems_to_fh($results, $ph); | ||
| 35 | close($ph); | ||
| 36 | if($results->{inconsistencies}) | ||
| 37 | { | ||
| 38 | fail $problems; | ||
| 39 | } | ||
| 40 | else | ||
| 41 | { | ||
| 42 | note $problems; | ||
| 43 | pass 'All permissions present found were consistent'; | ||
| 44 | } | ||
| 45 | } | ||
| 46 | else | ||
| 47 | { | ||
| 48 | pass 'All permissions consistent with ' . $authority_with; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | __END__ |