<commit_before>#! perl
# Copyright (C) 2006-2007, The Perl Foundation.
# $Id$

use strict;
use warnings;

use lib qw( . lib ../lib ../../lib );
use Test::More tests => 5;
use Parrot::Distribution;

=head1 NAME

t/codingstd/c_header_guards.t - checks for rules related to guards in C header files

=head1 SYNOPSIS

    # test all files
    % prove t/codingstd/c_header_guards.t

    # test specific files
    % perl t/codingstd/c_header_guards.t include/parrot/bar.h

=head1 DESCRIPTION

Checks that all C language header files have an
#ifndef PARROT_WHATEVER_H_GUARD definition, then they
#define PARROT_WHATEVER_H_GUARD and add an
#endif /* PARROT_WHATEVER_H_GUARD */ at the end, of the file as specified
in PDD07.

=head1 AUTHOR

<NAME> <mark at glines dot org>

=head1 SEE ALSO

L<docs/pdds/pdd07_codingstd.pod>

=cut

my $DIST = Parrot::Distribution->new();
my @files;
if (@ARGV) {
    @files = @ARGV;
}
else {
    my %files = map { $_->path() => 1 } $DIST->c_header_files();
    my $href = $DIST->generated_files();
    foreach my $file ( keys %$href ) {
        if ( $file =~ /\.h$/ ) {
            $files{$file} = 1 if -f $file;
        }
    }
    @files = sort keys %files;
}

check_header_guards(@files);
<commit_msg>[codingstd] Not all files should be subject to the header guards coding standard.  This commit gets the exemptions to be detected and removed  before checking the list of files.<commit_after>#! perl
# Copyright (C) 2006-2007, The Perl Foundation.
# $Id$

use strict;
use warnings;

use lib qw( . lib ../lib ../../lib );
use Test::More tests => 5;
use Parrot::Distribution;

=head1 NAME

t/codingstd/c_header_guards.t - checks for rules related to guards in C header files

=head1 SYNOPSIS

    # test all files
    % prove t/codingstd/c_header_guards.t

    # test specific files
    % perl t/codingstd/c_header_guards.t include/parrot/bar.h

=head1 DESCRIPTION

Checks that all C language header files have an
#ifndef PARROT_WHATEVER_H_GUARD definition, then they
#define PARROT_WHATEVER_H_GUARD and add an
#endif /* PARROT_WHATEVER_H_GUARD */ at the end, of the file as specified
in PDD07.

=head1 AUTHOR

<NAME> <mark at glines dot org>

=head1 SEE ALSO

L<docs/pdds/pdd07_codingstd.pod>

=cut

my $DIST = Parrot::Distribution->new();
my @files;
if (@ARGV) {
    @files = @ARGV;
}
else {
    my %files = map { $_->path() => 1 } $DIST->c_header_files();
    my $href = $DIST->generated_files();

    foreach my $file ( keys %$href ) {
        if ( $file =~ /\.h$/ ) {
            $files{$file} = 1 if -f $file;
        }
    }

    # not all files should be subject to the coding standards
    foreach my $file ( keys %files ) {
        if ( $DIST->is_c_exemption($file) ) {
            delete $files{$file};
        }
    }

    @files = sort keys %files;
}

check_header_guards(@files);

{'fraction_non_alphanumeric': 0.12349183818310859, 'fraction_numerical': 0.014194464158977998, 'mean_word_length': 3.0914368650217705, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2109581', 'n_tokens_mistral': 1069, 'n_tokens_neox': 984, 'n_words': 315}