From a8f90267fe9b45c3bea9543e7e4519d36b14f8c6 Mon Sep 17 00:00:00 2001 From: Nigel Horne Date: Sat, 30 Mar 2024 13:49:29 -0400 Subject: [PATCH] Use Test::Needs --- Makefile.PL | 1 + t/eof.t | 16 +++++----------- t/eol.t | 17 ++++++----------- t/links.t | 16 ++++++++-------- 4 files changed, 20 insertions(+), 30 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index 53dec43..29b3b57 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -16,6 +16,7 @@ WriteMakefile( 'LWP::Protocol::https' => 0, 'Test::Exception' => 0.42, # http://www.cpantesters.org/cpan/report/91a6ac80-6bf9-1014-b7eb-bb2be30b7e63 'Test::Most' => 0, + 'Test::Needs' => 0, 'Test::NoWarnings' => 0, 'Test::URI' => 0, 'Test::Timer' => 2.01, diff --git a/t/eof.t b/t/eof.t index f1365cb..f61ae39 100644 --- a/t/eof.t +++ b/t/eof.t @@ -2,20 +2,14 @@ use strict; use warnings; +use Test::Needs 'Test::EOF'; use Test::Most; BEGIN { - if($ENV{AUTHOR_TESTING}) { - eval { - require Test::EOF; - }; - if($@) { - plan(skip_all => 'Test::EOF not installed'); - } else { - import Test::EOF; - all_perl_files_ok({ minimum_newlines => 1, maximum_newlines => 4 }); - done_testing(); - } + if($ENV{'AUTHOR_TESTING'}) { + Test::EOF->import(); + all_perl_files_ok({ minimum_newlines => 1, maximum_newlines => 4 }); + done_testing(); } else { plan(skip_all => 'Author tests not required for installation'); } diff --git a/t/eol.t b/t/eol.t index 3360315..4a4d26c 100644 --- a/t/eol.t +++ b/t/eol.t @@ -1,19 +1,14 @@ +#!/usr/bin/env perl + use strict; use warnings; - +use Test::Needs 'Test::EOL'; use Test::Most; BEGIN { - if($ENV{AUTHOR_TESTING}) { - eval { - require Test::EOL; - }; - if($@) { - plan(skip_all => 'Test::EOL not installed'); - } else { - import Test::EOL; - all_perl_files_ok({ trailing_whitespace => 1 }); - } + if($ENV{'AUTHOR_TESTING'}) { + Test::EOL->import(); + all_perl_files_ok({ trailing_whitespace => 1 }); } else { plan(skip_all => 'Author tests not required for installation'); } diff --git a/t/links.t b/t/links.t index 27181d6..9c26c7c 100644 --- a/t/links.t +++ b/t/links.t @@ -4,13 +4,13 @@ use strict; use warnings; use Test::Most; -if(not $ENV{AUTHOR_TESTING}) { - plan(skip_all => 'Author tests not required for installation'); -} - -eval "use Test::Pod::LinkCheck"; -if($@) { - plan skip_all => 'Test::Pod::LinkCheck required for testing POD'; +if($ENV{AUTHOR_TESTING}) { + eval 'use Test::Pod::LinkCheck'; + if($@) { + plan(skip_all => 'Test::Pod::LinkCheck required for testing POD'); + } else { + Test::Pod::LinkCheck->new->all_pod_ok(); + } } else { - Test::Pod::LinkCheck->new->all_pod_ok(); + plan(skip_all => 'Author tests not required for installation'); }