Skip to content

Commit c505d73

Browse files
committed
implement perltidy author test
1 parent bf14a66 commit c505d73

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

xt/author/perltidy.t

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
use 5.010;
2+
use strictures 2;
3+
4+
=head1 DESCRIPTION
5+
6+
This test checks all perl files for tidyness, applying the local .perltidyrc rules. It is also set
7+
up to use a cache file generated by our in-dev version of Dist::Zilla::App::Command::perltidy. Said
8+
cache file normally lives in ~/.perltidychk.
9+
10+
=cut
11+
12+
use Test::More;
13+
use Test::PerlTidy;
14+
use Dist::Zilla::Path;
15+
use YAML;
16+
use Digest::SHA 'sha1_base64';
17+
use File::HomeDir;
18+
19+
run();
20+
21+
sub run {
22+
my %args = (
23+
exclude => [
24+
".build/", "_build/", "blib", ".git", ".vscode", #
25+
qr@^[A-Za-z].*-[0-9._]+(-TRIAL)?/@
26+
],
27+
perltidyrc => ".perltidyrc",
28+
);
29+
my @files = Test::PerlTidy::list_files(%args);
30+
31+
my %seen;
32+
my $seen_file = path( File::HomeDir->my_home, ".perltidychk" );
33+
%seen = %{ Load $seen_file->slurp_raw } if $seen_file->exists;
34+
my @to_skip = grep $seen{"./$_"}{ sha1_base64 path($_)->slurp_raw }, @files;
35+
return pass "all files tidy", done_testing if @files == @to_skip;
36+
37+
push @{ $args{exclude} }, @to_skip;
38+
@files = Test::PerlTidy::list_files(%args);
39+
40+
my @ok_files =
41+
grep ok( Test::PerlTidy::is_file_tidy( $_, $args{perltidyrc} ), "'$_'" ),
42+
@files;
43+
$seen{"./$_"}{ sha1_base64 path($_)->slurp_raw } = 1 for @ok_files;
44+
$seen_file->spew( Dump \%seen );
45+
46+
done_testing;
47+
48+
return;
49+
}

0 commit comments

Comments
 (0)