From 603da18917d873c78644b2aea193cb371c979974 Mon Sep 17 00:00:00 2001 From: schmonz Date: Tue, 26 Mar 2013 15:10:03 +0000 Subject: Declare package pkglint (not main) in pkglint.pl. This is more correct and more polite. For instance, pkglint.t no longer needs to declare a package of its own just for tests. --- pkgtools/pkglint/files/pkglint.pl | 4 ++-- pkgtools/pkglint/files/pkglint.t | 18 ++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) (limited to 'pkgtools') diff --git a/pkgtools/pkglint/files/pkglint.pl b/pkgtools/pkglint/files/pkglint.pl index ec860241749..e7273486f97 100644 --- a/pkgtools/pkglint/files/pkglint.pl +++ b/pkgtools/pkglint/files/pkglint.pl @@ -1,5 +1,5 @@ #! @PERL@ -# $NetBSD: pkglint.pl,v 1.851 2013/03/26 15:08:29 schmonz Exp $ +# $NetBSD: pkglint.pl,v 1.852 2013/03/26 15:10:03 schmonz Exp $ # # pkglint - static analyzer and checker for pkgsrc packages @@ -45,7 +45,7 @@ use PkgLint::SubstContext; use PkgLint::CVS_Entry; use PkgLint::Change; -package main; +package pkglint; #========================================================================== # This package contains the application-specific code of pkglint. # Most subroutines in this package follow a strict naming convention: diff --git a/pkgtools/pkglint/files/pkglint.t b/pkgtools/pkglint/files/pkglint.t index a02d5efeb28..52e0b139ba8 100644 --- a/pkgtools/pkglint/files/pkglint.t +++ b/pkgtools/pkglint/files/pkglint.t @@ -1,11 +1,9 @@ #! @PERL@ -# $NetBSD: pkglint.t,v 1.5 2013/03/26 15:05:27 schmonz Exp $ +# $NetBSD: pkglint.t,v 1.6 2013/03/26 15:10:03 schmonz Exp $ # require 'pkglint.pl'; # so we can test its internals -$main::program = 'pkglint.pl'; # because it self-greps for vartypes - -package PkgLint::Test; # pkglint.pl uses 'main', so we mustn't +$pkglint::program = 'pkglint.pl'; # because it self-greps for vartypes use Test::More tests => 37; use Test::Trap; @@ -66,7 +64,7 @@ sub test_program { } sub test_get_vartypes_basictypes { - my $unit = \&main::get_vartypes_basictypes; + my $unit = \&pkglint::get_vartypes_basictypes; my @results = test_unit($unit); my %types = %{$results[0]}; @@ -75,7 +73,7 @@ sub test_get_vartypes_basictypes { } sub test_get_vartypes_map { - my $unit = \&main::get_vartypes_map; + my $unit = \&pkglint::get_vartypes_map; my @results = test_unit($unit); my %map = %{$results[0]}; @@ -96,11 +94,11 @@ sub test_checkline_mk_vartype_basic { # (type='Restricted', value='RESTRICTED') # (type='SedCommands', a few different values') # once test coverage is persuasive, refactor to a dispatch table - # once refactored, get rid of the $main::program global + # once refactored, get rid of the $pkglint::program global } -sub test_main { - my $unit = \&main::main; +sub test_pkglint_main { + my $unit = \&pkglint::main; @ARGV = ('-h'); test_unit($unit, undef, 0, '^usage: pkglint ', '^$'); @@ -171,7 +169,7 @@ sub main { test_get_vartypes_basictypes(); test_get_vartypes_map(); test_checkline_mk_vartype_basic(); - test_main(); + test_pkglint_main(); test_lint_some_reference_packages(); } -- cgit v1.2.3