diff options
Diffstat (limited to 'tests/docs')
-rwxr-xr-x | tests/docs/pod-spelling-t | 7 | ||||
-rwxr-xr-x | tests/docs/pod-t | 7 | ||||
-rwxr-xr-x | tests/docs/spdx-license-t | 35 |
3 files changed, 32 insertions, 17 deletions
diff --git a/tests/docs/pod-spelling-t b/tests/docs/pod-spelling-t index 0419c24..04a89e5 100755 --- a/tests/docs/pod-spelling-t +++ b/tests/docs/pod-spelling-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, 2019 Russ Allbery <eagle@eyrie.org> # Copyright 2012-2014 # The Board of Trustees of the Leland Stanford Junior University # @@ -30,16 +30,17 @@ # # SPDX-License-Identifier: MIT -use 5.006; +use 5.008; use strict; use warnings; use lib "$ENV{C_TAP_SOURCE}/tap/perl"; -use Test::More; use Test::RRA qw(skip_unless_author use_prereq); use Test::RRA::Automake qw(automake_setup perl_dirs); +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/tests/docs/pod-t b/tests/docs/pod-t index 7ea3409..7b53dda 100755 --- a/tests/docs/pod-t +++ b/tests/docs/pod-t @@ -7,7 +7,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, 2019 Russ Allbery <eagle@eyrie.org> # Copyright 2012-2014 # The Board of Trustees of the Leland Stanford Junior University # @@ -31,16 +31,17 @@ # # SPDX-License-Identifier: MIT -use 5.006; +use 5.008; use strict; use warnings; use lib "$ENV{C_TAP_SOURCE}/tap/perl"; -use Test::More; use Test::RRA qw(skip_unless_automated use_prereq); use Test::RRA::Automake qw(automake_setup perl_dirs); +use Test::More; + # Skip this test for normal user installs, since we normally pre-generate all # of the documentation and the end user doesn't care. skip_unless_automated('POD syntax tests'); diff --git a/tests/docs/spdx-license-t b/tests/docs/spdx-license-t index 91072bf..d829080 100755 --- a/tests/docs/spdx-license-t +++ b/tests/docs/spdx-license-t @@ -9,7 +9,7 @@ # The canonical version of this file is maintained in the rra-c-util package, # which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>. # -# Copyright 2018 Russ Allbery <eagle@eyrie.org> +# Copyright 2018-2020 Russ Allbery <eagle@eyrie.org> # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -31,17 +31,18 @@ # # SPDX-License-Identifier: MIT -use 5.006; +use 5.008; use strict; use warnings; use lib "$ENV{C_TAP_SOURCE}/tap/perl"; -use File::Basename qw(basename); -use Test::More; use Test::RRA qw(skip_unless_automated); use Test::RRA::Automake qw(all_files automake_setup); +use File::Basename qw(basename); +use Test::More; + # File name (the file without any directory component) and path patterns to # skip for this check. ## no critic (RegularExpressions::ProhibitFixedStringMatches) @@ -68,10 +69,13 @@ my @IGNORE_PATHS = ( qr{ \A php/acinclude [.] m4 \z }xms, # Created by phpize qr{ \A php/build/ }xms, # Created by phpize qr{ \A php/config [.] (guess|sub) \z }xms, # Created by phpize - qr{ \A php/configure [.] in \z }xms, # Created by phpize + qr{ \A php/configure [.] (ac|in) \z }xms, # Created by phpize qr{ \A php/ltmain [.] sh \z }xms, # Created by phpize qr{ \A php/run-tests [.] php \z }xms, # Created by phpize + qr{ \A python/ .* [.] egg-info/ }xms, # Python build files + qr{ \A tests/config/ (?!README) }xms, # Test configuration qr{ [.] l?a \z }xms, # Created by libtool + qr{ [.] o \z }xms, # Compiler objects ); ## use critic @@ -91,9 +95,7 @@ sub check_file { my ($path) = @_; my $filename = basename($path); - # Ignore files in the whitelist, binary files, and files under 1KB. The - # latter can be rolled up into the overall project license and the license - # notice may be a substantial portion of the file size. + # Ignore files in the whitelist and binary files. for my $pattern (@IGNORE) { return if $filename =~ $pattern; } @@ -101,16 +103,18 @@ sub check_file { return if $path =~ $pattern; } return if !-T $path; - return if -s $path < 1024; # Scan the file. - my ($saw_spdx, $skip_spdx); + my ($saw_legacy_notice, $saw_spdx, $skip_spdx); open(my $file, '<', $path) or BAIL_OUT("Cannot open $path: $!"); while (defined(my $line = <$file>)) { if ($line =~ m{ Generated [ ] by [ ] libtool [ ] }xms) { close($file) or BAIL_OUT("Cannot close $path: $!"); return; } + if ($line =~ m{ \b See \s+ LICENSE \s+ for \s+ licensing }xms) { + $saw_legacy_notice = 1; + } if ($line =~ m{ \b SPDX-License-Identifier: \s+ \S+ }xms) { $saw_spdx = 1; last; @@ -121,7 +125,16 @@ sub check_file { } } close($file) or BAIL_OUT("Cannot close $path: $!"); - ok($saw_spdx || $skip_spdx, $path); + + # If there is a legacy license notice, report a failure regardless of file + # size. Otherwise, skip files under 1KB. They can be rolled up into the + # overall project license and the license notice may be a substantial + # portion of the file size. + if ($saw_legacy_notice) { + ok(!$saw_legacy_notice, "$path has legacy license notice"); + } else { + ok($saw_spdx || $skip_spdx || -s $path < 1024, $path); + } return; } |