From 72b2d822ad846dcc3a67e7a717d7ec3a3d3d0ab5 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 18 Mar 2025 16:24:17 +0100 Subject: [PATCH] Bug 39367: Add POD coverage tests --- xt/author/pod_coverage.t | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 xt/author/pod_coverage.t diff --git a/xt/author/pod_coverage.t b/xt/author/pod_coverage.t new file mode 100755 index 00000000000..c995e5b723a --- /dev/null +++ b/xt/author/pod_coverage.t @@ -0,0 +1,48 @@ +#!/usr/bin/env perl + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use Test::More; +use Test::NoWarnings; +use Pod::Coverage; + +# Note that we are using Pod::Coverage instead of Test::Pod::Coverage +# We do not want to fail if no pod exists in the file. +# That could be a next step + +my @files; +push @files, qx{git ls-files '*.pm'}; +chomp for @files; + +plan tests => scalar(@files) + 1; + +for my $file (@files) { + my @uncovered = check_pod_coverage($file); + is( scalar(@uncovered), 0, "POD coverage for $file" ) or diag( join ", ", @uncovered ); + +} + +sub check_pod_coverage { + my ($file) = @_; + + my $package_name = $file; + $package_name =~ s|/|::|g; + $package_name =~ s|\.pm$||; + + my $coverage = Pod::Coverage->new( package => $package_name ); + return $coverage->uncovered; +} -- 2.34.1