Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor t/Porting/Maintainers.pm to use Test::More instead of making TAP by hand #12457

Closed
p5pRT opened this issue Oct 3, 2012 · 5 comments
Closed

Comments

@p5pRT
Copy link

p5pRT commented Oct 3, 2012

Migrated from rt.perl.org#115116 (status was 'resolved')

Searchable as RT115116$

@p5pRT
Copy link
Author

p5pRT commented Oct 3, 2012

From @perlDreamer

In the same vein as the other test/module bridge,
ext/Pod-Functions/Functions_pm.PL.

@p5pRT
Copy link
Author

p5pRT commented Oct 3, 2012

From @perlDreamer

0002-Refactor-Porting-Maintainers.pm-to-use-Test-More-ins.patch
From 69b235fc51890cfbb958c55677778fed735ba51c Mon Sep 17 00:00:00 2001
From: Colin Kuskie <colink@perldreamer.com>
Date: Tue, 2 Oct 2012 18:19:14 -0700
Subject: [PATCH 2/2] Refactor Porting/Maintainers.pm to use Test::More
 instead of making TAP by hand.

---
 Porting/Maintainers.pm |   21 +++++----------------
 1 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/Porting/Maintainers.pm b/Porting/Maintainers.pm
index 8f0d052..519055c 100644
--- a/Porting/Maintainers.pm
+++ b/Porting/Maintainers.pm
@@ -302,6 +302,7 @@ sub show_results {
 	    }
 	}
     } elsif ($Check or $Checkmani) {
+        eval {use Test::More;};
         if( @Files ) {
 		    missing_maintainers(
 			$Checkmani
@@ -348,21 +349,13 @@ sub maintainers_files {
 sub duplicated_maintainers {
     maintainers_files();
     for my $f (keys %files) {
-	if ($files{$f} > 1) {
-	    print  "not ok ".++$TestCounter." - File $f appears $files{$f} times in Maintainers.pl\n";
-	} else {
-	    print  "ok ".++$TestCounter." - File $f appears $files{$f} times in Maintainers.pl\n";
-	}
+        cmp_ok($files{$f}, '<=', 1, "File $f appears $files{$f} times in Maintainers.pl");
     }
 }
 
 sub warn_maintainer {
     my $name = shift;
-    if ($files{$name}) {
-	print "ok ".++$TestCounter." - $name has a maintainer\n";
-    } else {
-	print "not ok ".++$TestCounter." - $name has NO maintainer\n";
-    }
+    ok($files{$name}, "$name has a maintainer");
 }
 
 sub missing_maintainers {
@@ -378,16 +371,12 @@ sub missing_maintainers {
 sub superfluous_maintainers {
     maintainers_files();
     for my $f (keys %files) {
-	if ($MANIFEST{$f}) {
-	    print "ok ".++$TestCounter." - Maintained file $f appears in MANIFEST\n";
-	} else {
-	    print "not ok ".++$TestCounter." - File $f has has a maintainer but is not in MANIFEST\n";
-	}
+        ok($MANIFEST{$f}, "File $f has a maintainer and is in MANIFEST");
     }
 }
 
 sub finish_tap_output {
-    print "1..".$TestCounter."\n"; 
+    done_testing();
 }
 
 1;
-- 
1.7.5.4

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2012

From @tsee

Thanks, applied as ec9012a.

I did a small modification​:

eval {use Test​::More} will still die if Test​::More isn't available. Even
if that code is never actually executed at run-time. The use statement
works at begin time.

What you wanted is probably either eval "use Test​::More" or simply​:

  require Test​::More;
  Test​::More->import;

which is what I replaced it with.

Furthermore, I find it quite ironic that Porting/Maintainers.pm requires
version updates according to cmp_version.t. :)

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2012

From [Unknown Contact. See original ticket]

Thanks, applied as ec9012a.

I did a small modification​:

eval {use Test​::More} will still die if Test​::More isn't available. Even
if that code is never actually executed at run-time. The use statement
works at begin time.

What you wanted is probably either eval "use Test​::More" or simply​:

  require Test​::More;
  Test​::More->import;

which is what I replaced it with.

Furthermore, I find it quite ironic that Porting/Maintainers.pm requires
version updates according to cmp_version.t. :)

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2012

@tsee - Status changed from 'new' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant