Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: nqp-p6
Fetching contributors…

Cannot retrieve contributors at this time

82 lines (57 sloc) 1.787 kB
#! perl
# Copyright (C) 2006-2009, Parrot Foundation.
use strict;
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
use ExtUtils::Manifest qw(maniread);
use Parrot::Distribution;
# set up how many tests to run
plan tests => 1;
=head1 NAME
t/codingstd/gmt_utc.t - checks for GMT/UTC timezone in generated files
=head1 SYNOPSIS
# test all files
% prove t/codingstd/gmt_utc.t
# test specific files
% perl t/codingstd/gmt_utc.t src/foo.c include/parrot/bar.h
=head1 DESCRIPTION
Generated files which have timezone information should have this as either
GMT or UTC.
=head1 SEE ALSO
L<docs/pdds/pdd07_codingstd.pod>
=cut
my $DIST = Parrot::Distribution->new;
my @files = @ARGV ? <@ARGV> : source_files();
my @failures;
foreach my $file (@files) {
my $buf = $DIST->slurp($file);
# trim out SVN Id line
$buf =~ s{\$Id:.*}{}g;
# if we have a timezone, check to see if it is GMT/UTC
push @failures => "$file\n"
if $buf =~ m{
\d:\d\d:\d\d # a time-looking string
(?! .*? (GMT|UTC)) # not GMT or UTC
}x;
}
ok( !scalar(@failures), 'Generated timestamps correct' )
or diag( "Non GMT/UTC timestamp found in " . scalar @failures . " files:\n@failures" );
exit;
sub source_files {
my $manifest = maniread('MANIFEST.generated');
my @test_files;
# grab names of files to test (except binary files)
foreach my $filename ( sort keys %$manifest ) {
next if !( -e $filename );
push @test_files, $filename
if ( $filename =~ m/\.(c|h|pod|pl|pm)$/ );
}
return @test_files;
}
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4:
Jump to Line
Something went wrong with that request. Please try again.