[svn:parrot] r37603 - in trunk: lib/Parrot/Test t/examples

coke at svn.parrot.org coke at svn.parrot.org
Fri Mar 20 01:10:16 UTC 2009


Author: coke
Date: Fri Mar 20 01:10:13 2009
New Revision: 37603
URL: https://trac.parrot.org/parrot/changeset/37603

Log:
Test /all/ POD files when trying to compile PIR.
switch our check to just compile the code, not try to run it. (similar to t/examples/catchall.t)

Modified:
   trunk/lib/Parrot/Test/Pod.pm
   trunk/t/examples/pod.t

Modified: trunk/lib/Parrot/Test/Pod.pm
==============================================================================
--- trunk/lib/Parrot/Test/Pod.pm	Thu Mar 19 23:33:53 2009	(r37602)
+++ trunk/lib/Parrot/Test/Pod.pm	Fri Mar 20 01:10:13 2009	(r37603)
@@ -176,7 +176,7 @@
         if ($@) {
             croak "$sto exists on disk but could not retrieve from it";
         }
-        else {
+        elsif (exists $args->{second_analysis}) {
             # go to second-level analysis
             $files_needing_analysis =
                 $second_analysis_subs{$args->{second_analysis}}(
@@ -227,11 +227,13 @@
         }
         nstore $files_needing_analysis, $sto;
         # go to second-level analysis
-        $files_needing_analysis =
-            $second_analysis_subs{$args->{second_analysis}}(
-                $files_needing_analysis,
-                $self->{build_dir},
-            );
+        if (exists $args->{second_analysis}) {
+            $files_needing_analysis =
+                $second_analysis_subs{$args->{second_analysis}}(
+                    $files_needing_analysis,
+                    $self->{build_dir},
+                );
+        }
     }
 
     return [ keys %{ $files_needing_analysis } ];

Modified: trunk/t/examples/pod.t
==============================================================================
--- trunk/t/examples/pod.t	Thu Mar 19 23:33:53 2009	(r37602)
+++ trunk/t/examples/pod.t	Fri Mar 20 01:10:13 2009	(r37603)
@@ -6,8 +6,12 @@
 use warnings;
 use lib qw( . lib ../lib ../../lib );
 
+use File::Temp qw(tempfile);
 use Test::More qw(no_plan);
+
 use Parrot::Test;
+use Parrot::Config qw(%PConfig);
+
 
 use lib qw( lib );
 BEGIN {
@@ -22,18 +26,33 @@
     argv => [ @ARGV ],
 } );
 
-my $need_testing_ref = $self->identify_files_for_POD_testing( {
-    second_analysis => 'oreilly_summary_malformed',
-} );
+my $need_testing_ref = $self->identify_files_for_POD_testing();
 
 foreach my $file ( @{ $need_testing_ref } ) {
     foreach my $contents (get_samples($file)) {
-        pir_output_like($contents,qr//,"$file\n$contents");
+        compile_pir_ok($contents, $file);
     }
 }
 
 #################### SUBROUTINES ####################
 
+sub compile_pir_ok {
+    my $code = shift;
+    my $file = shift;
+
+    my ($fh,$tempfile) = tempfile(SUFFIX => '.pir', UNLINK => 1);
+    print {$fh} $code;
+    close $fh;
+
+    my $cmd = File::Spec->curdir() . $PConfig{slash} .
+              $PConfig{test_prog} . " -o " . File::Spec->devnull() . " " .
+              $tempfile;
+
+    my $description = "$file\n$code";
+
+    is(system($cmd), 0 , $description);
+}
+
 sub get_samples {
     my $file = shift;
 
@@ -61,8 +80,9 @@
 
 =head1 DESCRIPTION
 
-Tests the syntax for any embedded PIR for all files listed in F<MANIFEST> and
-F<MANIFEST.generated>. Any invalid examples are reported in the test output.
+Tests the syntax for any embedded PIR in POD, for all files in the
+repository that contain POD.  Any invalid examples are reported in the
+test output.
 
 =cut
 


More information about the parrot-commits mailing list