This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fold_grind.t: read environment variable just once
authorKarl Williamson <public@khwilliamson.com>
Tue, 27 Mar 2012 13:26:47 +0000 (07:26 -0600)
committerKarl Williamson <public@khwilliamson.com>
Sat, 2 Jun 2012 14:29:14 +0000 (08:29 -0600)
Setting a lexical variable to the environment variable made it easier
for me to temporarily override things during a sequence of tests that
took place on many different occasions where I needed this set and kept
forgetting to set the environment variable.

t/re/fold_grind.t

index e2153e3..3e5be81 100644 (file)
@@ -74,6 +74,8 @@ sub numerically {
     return $a <=> $b
 }
 
+my $list_all_tests = $ENV{PERL_DEBUG_FULL_TEST};
+
 # Significant time is saved by not outputting each test but grouping the
 # output into subtests
 my $okays;          # Number of ok's in current subtest
@@ -86,7 +88,7 @@ sub run_test($$$) {
     $debug = "" unless $DEBUG;
     my $res = eval $test;
 
-    if (!$res || $ENV{PERL_DEBUG_FULL_TEST}) {
+    if (!$res || $list_all_tests) {
       # Failed or debug; output the result
       $count++;
       ok($res, "$test; $debug");
@@ -732,7 +734,7 @@ foreach my $test (sort { numerically } keys %tests) {
                           utf8::upgrade($p) if length($upgrade_pattern);
                           my $res = $op ? ($c =~ $p): ($c !~ $p);
 
-                          if (!$res || $ENV{PERL_DEBUG_FULL_TEST}) {
+                          if (!$res || $list_all_tests) {
                             # Failed or debug; output the result
                             $count++;
                             ok($res, "test $count - $desc");
@@ -751,7 +753,7 @@ foreach my $test (sort { numerically } keys %tests) {
           }
         }
       }
-      unless($ENV{PERL_DEBUG_FULL_TEST}) {
+      unless($list_all_tests) {
         $count++;
         is $okays, $this_iteration, "$okays subtests ok for"
           . " /$charset,"