In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/8c8273e3a8fb69fa8e9d9bca975ed4c97278ca5d?hp=3ab0c9fa54624be5755cc8455627b6b85054a056>
- Log ----------------------------------------------------------------- commit 8c8273e3a8fb69fa8e9d9bca975ed4c97278ca5d Author: Nicholas Clark <[email protected]> Date: Mon Sep 14 13:34:10 2009 +0100 Convert Porting/checkARGS_ASSERT.pl to a regresion test, t/lib/args_assert.t M MANIFEST D Porting/checkARGS_ASSERT.pl A t/lib/args_assert.t commit 28eb953d1558a268eaab7eac243c13126fb02a10 Author: Nicholas Clark <[email protected]> Date: Mon Sep 14 13:32:38 2009 +0100 Add PERL_ARGS_ASSERT_* macros where missing; move where in the wrong function. M dump.c ----------------------------------------------------------------------- Summary of changes: MANIFEST | 2 +- Porting/checkARGS_ASSERT.pl | 32 ------------------------ dump.c | 12 ++++++--- t/lib/args_assert.t | 56 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 37 deletions(-) delete mode 100755 Porting/checkARGS_ASSERT.pl create mode 100644 t/lib/args_assert.t diff --git a/MANIFEST b/MANIFEST index 96b3af6..ce6279c 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3933,7 +3933,6 @@ Porting/add-package.pl Add/Update CPAN modules that are part of Core Porting/bump-perl-version bump the perl version in relevant files Porting/check83.pl Check whether we are 8.3-friendly Porting/checkansi.pl Check source code for ANSI-C violations -Porting/checkARGS_ASSERT.pl Check we use every PERL_ARGS_ASSERT* macro Porting/checkAUTHORS.pl Check that the AUTHORS file is complete Porting/checkcfgvar.pl Check that config scripts define all symbols Porting/checkURL.pl Check whether we have working URLs @@ -4172,6 +4171,7 @@ t/io/through.t See if pipe passes data intact t/io/utf8.t See if file seeking works t/japh/abigail.t Obscure tests t/lib/1_compile.t See if the various libraries and extensions compile +t/lib/args_assert.t Check that all PERL_ARGS_ASSERT* macros are used t/lib/Cname.pm Test charnames in regexes (op/pat.t) t/lib/common.pl Helper for lib/{warnings,feature}.t t/lib/commonsense.t See if configuration meets basic needs diff --git a/Porting/checkARGS_ASSERT.pl b/Porting/checkARGS_ASSERT.pl deleted file mode 100755 index 3d8e2fc..0000000 --- a/Porting/checkARGS_ASSERT.pl +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/perl -w -use strict; - -# Print out any PERL_ARGS_ASSERT* macro that was declared but not used. - -my %declared; -my %used; - -open my $fh, '<', 'proto.h' or die "Can't open proto.h: $!"; -while (<$fh>) { - $declared{$1}++ if /^#define\s+(PERL_ARGS_ASSERT[A-Za-z_]+)\s+/; -} - -if (!...@argv) { - open my $fh, '<', 'MANIFEST' or die "Can't open MANIFEST: $!"; - while (<$fh>) { - # *.c or */*.c - push @ARGV, $1 if m!^((?:[^/]+/)?[^/]+\.c)\t!; - } -} - -while (<>) { - $used{$1}++ if /^\s+(PERL_ARGS_ASSERT_[A-Za-z_]+);$/; -} - -my %unused; - -foreach (keys %declared) { - $unused{$_}++ unless $used{$_}; -} - -print $_, "\n" foreach sort keys %unused; diff --git a/dump.c b/dump.c index f5f42ee..fae2d11 100644 --- a/dump.c +++ b/dump.c @@ -109,6 +109,7 @@ Perl_dump_all_perl(pTHX_ bool justperl) void Perl_dump_packsubs(pTHX_ const HV *stash) { + PERL_ARGS_ASSERT_DUMP_PACKSUBS; dump_packsubs_perl(stash, FALSE); } @@ -118,7 +119,7 @@ Perl_dump_packsubs_perl(pTHX_ const HV *stash, bool justperl) dVAR; I32 i; - PERL_ARGS_ASSERT_DUMP_PACKSUBS; + PERL_ARGS_ASSERT_DUMP_PACKSUBS_PERL; if (!HvARRAY(stash)) return; @@ -144,6 +145,7 @@ Perl_dump_packsubs_perl(pTHX_ const HV *stash, bool justperl) void Perl_dump_sub(pTHX_ const GV *gv) { + PERL_ARGS_ASSERT_DUMP_SUB; dump_sub_perl(gv, FALSE); } @@ -152,7 +154,7 @@ Perl_dump_sub_perl(pTHX_ const GV *gv, bool justperl) { SV * sv; - PERL_ARGS_ASSERT_DUMP_SUB; + PERL_ARGS_ASSERT_DUMP_SUB_PERL; if (justperl && (CvISXSUB(GvCV(gv)) || !CvROOT(GvCV(gv)))) return; @@ -2231,6 +2233,7 @@ Perl_xmldump_all_perl(pTHX_ bool justperl) void Perl_xmldump_packsubs(pTHX_ const HV *stash) { + PERL_ARGS_ASSERT_XMLDUMP_PACKSUBS; xmldump_packsubs_perl(stash, FALSE); } @@ -2240,7 +2243,7 @@ Perl_xmldump_packsubs_perl(pTHX_ const HV *stash, bool justperl) I32 i; HE *entry; - PERL_ARGS_ASSERT_XMLDUMP_PACKSUBS; + PERL_ARGS_ASSERT_XMLDUMP_PACKSUBS_PERL; if (!HvARRAY(stash)) return; @@ -2264,6 +2267,7 @@ Perl_xmldump_packsubs_perl(pTHX_ const HV *stash, bool justperl) void Perl_xmldump_sub(pTHX_ const GV *gv) { + PERL_ARGS_ASSERT_XMLDUMP_SUB; xmldump_sub_perl(gv, FALSE); } @@ -2272,7 +2276,7 @@ Perl_xmldump_sub_perl(pTHX_ const GV *gv, bool justperl) { SV * sv; - PERL_ARGS_ASSERT_XMLDUMP_SUB; + PERL_ARGS_ASSERT_XMLDUMP_SUB_PERL; if (justperl && (CvISXSUB(GvCV(gv)) || !CvROOT(GvCV(gv)))) return; diff --git a/t/lib/args_assert.t b/t/lib/args_assert.t new file mode 100644 index 0000000..bf42d0f --- /dev/null +++ b/t/lib/args_assert.t @@ -0,0 +1,56 @@ +#!perl + +use strict; +use warnings; + +use Test::More 'no_plan'; + +# Fail for every PERL_ARGS_ASSERT* macro that was declared but not used. + +my %declared; +my %used; + +my $prefix = ''; + +unless (-d 't' && -f 'MANIFEST') { + # we'll assume that we are in t then. + # All files are interal to perl, so Unix-style is sufficiently portable. + $prefix = '../'; +} + +{ + my $proto = $prefix . 'proto.h'; + + open my $fh, '<', $proto or die "Can't open $proto: $!"; + + while (<$fh>) { + $declared{$1}++ if /^#define\s+(PERL_ARGS_ASSERT[A-Za-z_]+)\s+/; + } +} + +cmp_ok(scalar keys %declared, '>', 0, 'Some macros were declared'); + +if (!...@argv) { + my $manifest = $prefix . 'MANIFEST'; + open my $fh, '<', $manifest or die "Can't open $manifest: $!"; + while (<$fh>) { + # *.c or */*.c + push @ARGV, $prefix . $1 if m!^((?:[^/]+/)?[^/]+\.c)\t!; + } +} + +while (<>) { + $used{$1}++ if /^\s+(PERL_ARGS_ASSERT_[A-Za-z_]+);$/; +} + +my %unused; + +foreach (keys %declared) { + $unused{$_}++ unless $used{$_}; +} + +if (keys %unused) { + fail("$_ is declared but not used") foreach sort keys %unused; +} else { + pass('Every PERL_ARGS_ASSERT* macro declared is used'); +} -- Perl5 Master Repository
