diff options
Diffstat (limited to 'perl/t')
-rwxr-xr-x | perl/t/docs/pod-spelling.t | 6 | ||||
-rwxr-xr-x | perl/t/docs/pod.t | 6 | ||||
-rwxr-xr-x | perl/t/style/minimum-version.t | 6 | ||||
-rwxr-xr-x | perl/t/style/strict.t | 50 | ||||
-rwxr-xr-x | perl/t/verifier/ldap-attr.t | 7 | ||||
-rwxr-xr-x | perl/t/verifier/netdb.t | 11 |
6 files changed, 60 insertions, 26 deletions
diff --git a/perl/t/docs/pod-spelling.t b/perl/t/docs/pod-spelling.t index 94d7503..819aa69 100755 --- a/perl/t/docs/pod-spelling.t +++ b/perl/t/docs/pod-spelling.t @@ -6,6 +6,7 @@ # which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>. # # Written by Russ Allbery <eagle@eyrie.org> +# Copyright 2019 Russ Allbery <eagle@eyrie.org> # Copyright 2013-2014 # The Board of Trustees of the Leland Stanford Junior University # @@ -29,15 +30,16 @@ # # SPDX-License-Identifier: MIT -use 5.006; +use 5.008; use strict; use warnings; use lib 't/lib'; -use Test::More; use Test::RRA qw(skip_unless_author use_prereq); +use Test::More; + # Only run this test for the module author since the required stopwords are # too sensitive to the exact spell-checking program and dictionary. skip_unless_author('Spelling tests'); diff --git a/perl/t/docs/pod.t b/perl/t/docs/pod.t index 5fcfcdf..e7d0231 100755 --- a/perl/t/docs/pod.t +++ b/perl/t/docs/pod.t @@ -6,6 +6,7 @@ # which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>. # # Written by Russ Allbery <eagle@eyrie.org> +# Copyright 2019 Russ Allbery <eagle@eyrie.org> # Copyright 2012-2014 # The Board of Trustees of the Leland Stanford Junior University # @@ -29,15 +30,16 @@ # # SPDX-License-Identifier: MIT -use 5.006; +use 5.008; use strict; use warnings; use lib 't/lib'; -use Test::More; use Test::RRA qw(skip_unless_automated use_prereq); +use Test::More; + # Skip this test for normal user installs, although pod2man may still fail. skip_unless_automated('POD syntax tests'); diff --git a/perl/t/style/minimum-version.t b/perl/t/style/minimum-version.t index 7698c2b..861367d 100755 --- a/perl/t/style/minimum-version.t +++ b/perl/t/style/minimum-version.t @@ -6,6 +6,7 @@ # which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>. # # Written by Russ Allbery <eagle@eyrie.org> +# Copyright 2019 Russ Allbery <eagle@eyrie.org> # Copyright 2013-2014 # The Board of Trustees of the Leland Stanford Junior University # @@ -29,16 +30,17 @@ # # SPDX-License-Identifier: MIT -use 5.006; +use 5.008; use strict; use warnings; use lib 't/lib'; -use Test::More; use Test::RRA qw(skip_unless_automated use_prereq); use Test::RRA::Config qw($MINIMUM_VERSION); +use Test::More; + # Skip for normal user installs since this doesn't affect functionality. skip_unless_automated('Minimum version tests'); diff --git a/perl/t/style/strict.t b/perl/t/style/strict.t index a3d2a3e..a87c1fa 100755 --- a/perl/t/style/strict.t +++ b/perl/t/style/strict.t @@ -6,7 +6,7 @@ # which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>. # # Written by Russ Allbery <eagle@eyrie.org> -# Copyright 2016 Russ Allbery <eagle@eyrie.org> +# Copyright 2016, 2018-2019 Russ Allbery <eagle@eyrie.org> # Copyright 2013-2014 # The Board of Trustees of the Leland Stanford Junior University # @@ -30,15 +30,16 @@ # # SPDX-License-Identifier: MIT -use 5.006; +use 5.008; use strict; use warnings; use lib 't/lib'; -use File::Spec; use Test::RRA qw(skip_unless_automated use_prereq); +use File::Spec; + # Skip for normal user installs since this doesn't affect functionality. skip_unless_automated('Strictness tests'); @@ -46,15 +47,40 @@ skip_unless_automated('Strictness tests'); # use 5.012 or later automatically implies use strict. use_prereq('Test::Strict', '0.25'); -# Test everything in the distribution directory except the Build and -# Makefile.PL scripts generated by Module::Build. We also want to check use -# warnings. -$Test::Strict::TEST_SKIP = ['Build', 'Makefile.PL']; +# Directories to exclude from checks. +my %EXCLUDE = map { $_ => 1 } qw(.git blib); + +# Determine whether we want to check the given file or top-level directory. +# Assume that the only interesting files at the top level are directories or +# files ending in *.PL. +# +# $file - Name of the file or directory +# +# Returns: 1 if it should be checked, undef otherwise. +sub should_check { + my ($file) = @_; + return if $EXCLUDE{$file}; + return 1 if -d $file; + return 1 if $file =~ m{ [.] PL \z }xms; + return; +} + +# Test::Strict (as of 0.47) doesn't have a way of excluding whole directories +# from all_perl_files_ok and doesn't exclude .git, which results in false +# positives if there are Perl files unpacked under .git (which is often the +# case when using dgit). We therefore can't just point it at the root of the +# module distribution and instead have to manually construct a list of +# interesting files. +opendir(my $rootdir, File::Spec->curdir) + or die "$0: cannot open current directory: $!\n"; +my @files = File::Spec->no_upwards(readdir($rootdir)); +closedir($rootdir) or die "$0: cannot close current directory: $!\n"; +my @to_check = grep { should_check($_) } @files; + +# Test the files and top-level directories we found, including checking for +# use warnings. $Test::Strict::TEST_WARNINGS = 1; -all_perl_files_ok(File::Spec->curdir); +all_perl_files_ok(@to_check); # Hack to suppress "used only once" warnings. -END { - $Test::Strict::TEST_SKIP = []; - $Test::Strict::TEST_WARNINGS = 0; -} +END { $Test::Strict::TEST_WARNINGS = 0 } diff --git a/perl/t/verifier/ldap-attr.t b/perl/t/verifier/ldap-attr.t index 321822d..4448b38 100755 --- a/perl/t/verifier/ldap-attr.t +++ b/perl/t/verifier/ldap-attr.t @@ -6,7 +6,7 @@ # access to the LDAP server and will be skipped in all other environments. # # Written by Russ Allbery <eagle@eyrie.org> -# Copyright 2018 Russ Allbery <eagle@eyrie.org> +# Copyright 2018, 2020 Russ Allbery <eagle@eyrie.org> # Copyright 2012-2014 # The Board of Trustees of the Leland Stanford Junior University # @@ -15,12 +15,13 @@ use strict; use warnings; -use Test::More; - use lib 't/lib'; + use Test::RRA qw(skip_unless_author); use Util; +use Test::More; + # This test requires a specific environment setup, so only run it for package # maintainers. skip_unless_author('LDAP verifier tests'); diff --git a/perl/t/verifier/netdb.t b/perl/t/verifier/netdb.t index c9e63d3..2a28468 100755 --- a/perl/t/verifier/netdb.t +++ b/perl/t/verifier/netdb.t @@ -7,7 +7,7 @@ # environments. # # Written by Russ Allbery <eagle@eyrie.org> -# Copyright 2018 Russ Allbery <eagle@eyrie.org> +# Copyright 2018, 2020 Russ Allbery <eagle@eyrie.org> # Copyright 2008, 2014 # The Board of Trustees of the Leland Stanford Junior University # @@ -16,14 +16,15 @@ use strict; use warnings; -use Test::More; - -use Wallet::ACL::NetDB; - use lib 't/lib'; + use Test::RRA qw(skip_unless_author); use Util; +use Test::More; + +use Wallet::ACL::NetDB; + # This test requires a specific environment setup, so only run it for package # maintainers. skip_unless_author('NetDB verifier tests'); |