add and change NEWS for 2.8.0 release
[parrot.git] / t / codingstd / make_code_coda.t
blobecce6b416e8d63412526c79585aa71d34074ed0d
1 #! perl
2 # Copyright (C) 2009, Parrot Foundation.
3 # $Id$
5 use strict;
6 use warnings;
8 use lib qw( . lib ../lib ../../lib );
9 use Test::More tests => 2;
10 use Parrot::Distribution;
11 use Parrot::Test::Util::Runloop;
13 =head1 NAME
15 t/codingstd/make_code_coda.t - checks for editor hint coda in Make source
17 =head1 SYNOPSIS
19     # test all files
20     % prove t/codingstd/make_code_coda.t
22     # test specific files
23     % perl t/codingstd/make_code_coda.t config/gen/makefiles/pge.in
25 =head1 DESCRIPTION
27 Checks that all Make language source files have the proper editor hints coda,
28 as specified in PDD07.
30 =head1 SEE ALSO
32 L<docs/pdds/pdd07_codingstd.pod>
34 =cut
36 my $coda = <<'CODA';
37 # Local variables:
38 #   mode: makefile
39 # End:
40 # vim: ft=make:
41 CODA
43 my $DIST = Parrot::Distribution->new;
44 my @files = @ARGV ? <@ARGV> : $DIST->get_make_language_files();
46 Parrot::Test::Util::Runloop->testloop(
47     name        => 'every file has a coda',
48     files       => [@files],
49     per_file    => sub { shift =~ m{\Q$coda\E\n*\z} },
50     diag_prefix => 'No coda found'
53 Parrot::Test::Util::Runloop->testloop(
54     name        => 'only one coda per file',
55     files       => [@files],
56     per_file    => \&check_duplicates,
57     diag_prefix => 'Duplicate coda found'
60 sub check_duplicates {
61     my $buf = shift;
63     # append to the extra_coda array if coda-like text appears more than once
64     my $vim_many = 0;
65     $vim_many++ while $buf =~ m{^ [* \t]* vim[:] }gmx;
66     my $emacs_many = 0;
67     $emacs_many++ while $buf =~ m{^ [* \t]* Local \s variables: }gmx;
68     return ($vim_many <= 1 && $emacs_many <= 1);
71 # Local Variables:
72 #   mode: cperl
73 #   cperl-indent-level: 4
74 #   fill-column: 100
75 # End:
76 # vim: expandtab shiftwidth=4: