[svn:parrot] r49460 - in branches/tt1810_missing_step_tests: lib/Parrot/Configure/Options/Test t/configure

jkeenan at svn.parrot.org jkeenan at svn.parrot.org
Wed Oct 6 01:43:03 UTC 2010


Author: jkeenan
Date: Wed Oct  6 01:43:03 2010
New Revision: 49460
URL: https://trac.parrot.org/parrot/changeset/49460

Log:
Introduce and test get_steps_missing_tests().

Modified:
   branches/tt1810_missing_step_tests/lib/Parrot/Configure/Options/Test/Prepare.pm
   branches/tt1810_missing_step_tests/t/configure/049-options_test_prepare.t

Modified: branches/tt1810_missing_step_tests/lib/Parrot/Configure/Options/Test/Prepare.pm
==============================================================================
--- branches/tt1810_missing_step_tests/lib/Parrot/Configure/Options/Test/Prepare.pm	Wed Oct  6 00:21:50 2010	(r49459)
+++ branches/tt1810_missing_step_tests/lib/Parrot/Configure/Options/Test/Prepare.pm	Wed Oct  6 01:43:03 2010	(r49460)
@@ -4,13 +4,12 @@
 use strict;
 use warnings;
 use Carp;
-use Data::Dumper;$Data::Dumper::Indent=1;
 use File::Find;
-#use Scalar::Util qw( looks_like_number );
 use base qw( Exporter );
 our @EXPORT_OK = qw(
     get_preconfiguration_tests
     get_postconfiguration_tests
+    get_steps_missing_tests
 );
 use lib qw(lib);
 use Parrot::Configure::Step::List qw( get_steps_list );
@@ -22,7 +21,7 @@
 my ( $steps_tests_simple_ref, $steps_tests_complex_ref )  =
     _find_steps_tests($steps_dir);
 my @steps_expected = get_steps_list();
-my @steps_tests = _prepare_steps_tests_list(
+my ($steps_tests_ref, $steps_missing_tests_ref) = _prepare_steps_tests_list(
     $steps_dir,
     $steps_tests_complex_ref,
     \@steps_expected,
@@ -34,13 +33,17 @@
 
 sub get_postconfiguration_tests {
     my @postconfiguration_tests = (
-        @steps_tests,
+        @{$steps_tests_ref},
         glob("t/postconfigure/*.t"),
         glob("t/pharness/*.t"),
     );
     return @postconfiguration_tests;
 };
 
+sub get_steps_missing_tests {
+    return @{$steps_missing_tests_ref};
+}
+
 ########## INTERNAL SUBROUTINES ##########
 
 sub _get_framework_tests {
@@ -87,16 +90,14 @@
 }
 
 sub _prepare_steps_tests_list {
-    my $steps_dir = shift;
-    my $steps_tests_ref = shift;
-    my $steps_expected_ref = shift;
-    my @steps_tests;
+    my ($steps_dir, $steps_tests_ref, $steps_expected_ref) = @_;
+    my (@steps_tests, @steps_lacking_tests);
     # The order of tests of config steps is governed by
     # Parrot::Configure::Step::List::get_steps_list().
     foreach my $step ( @{ $steps_expected_ref } ) {
         my @module_path = split /::/, $step;
         my $these_tests = $steps_tests_ref->{$module_path[0]}{$module_path[1]}
-            or carp "No tests exist for configure step $step";
+            or push @steps_lacking_tests, $step;
         foreach my $k (sort keys %$these_tests) {
             if ( $k =~ m/^(\w+)-(\d{2})$/ ) {
                 my ($secondlevel, $number) = ($1, $2);
@@ -109,7 +110,7 @@
             }
         }
     }
-    return @steps_tests;
+    return (\@steps_tests, \@steps_lacking_tests);
 }
 
 1;
@@ -132,6 +133,7 @@
     use Parrot::Configure::Options::Test::Prepare qw(
         get_preconfiguration_tests
         get_postconfiguration_tests
+        get_steps_missing_tests
     );
 
     ...
@@ -163,6 +165,12 @@
     t/tools/pmc2cutils/
     t/pharness/
 
+=item * C<get_steps_missing_tests()>
+
+Returns a list of those configuration steps (in format like, I<e.g.,>
+C<auto::stat>) those configuration steps currently lacking tests in
+F<t/steps/>.
+
 =back
 
 =head1 AUTHOR

Modified: branches/tt1810_missing_step_tests/t/configure/049-options_test_prepare.t
==============================================================================
--- branches/tt1810_missing_step_tests/t/configure/049-options_test_prepare.t	Wed Oct  6 00:21:50 2010	(r49459)
+++ branches/tt1810_missing_step_tests/t/configure/049-options_test_prepare.t	Wed Oct  6 01:43:03 2010	(r49460)
@@ -10,9 +10,8 @@
 use File::Basename qw( basename fileparse );
 use File::Path qw( mkpath );
 use File::Temp 0.13 qw| tempdir |;
-use Test::More tests => 10;
+use Test::More tests => 12;
 use lib qw( lib );
-use IO::CaptureOutput qw| capture |;
 use Parrot::Configure::Options::Test::Prepare ();
 
 my $cwd = cwd();
@@ -75,24 +74,22 @@
         auto::sometest
         gen::sometest
     );
-    my $not_expected = q{gen::missing};
-    push @tests_expected, $not_expected;
-    my %tests_seen = ();
-    {
-        my ($stdout, $stderr);
-        capture (
-            sub { %tests_seen = map { $_, 1}
-                Parrot::Configure::Options::Test::Prepare::_prepare_steps_tests_list(
-                    $tdir,
-                    $steps_tests_complex_ref,
-                    \@tests_expected,
-                ) },
-            \$stdout,
-            \$stderr,
+    my @not_expected = ( q{gen::missing}, q{auto::fabulous} );
+    my @all_tests = ();
+    push @all_tests, (@tests_expected, @not_expected);
+    my ( $steps_tests_ref, $steps_lacking_tests_ref) =
+        Parrot::Configure::Options::Test::Prepare::_prepare_steps_tests_list(
+            $tdir,
+            $steps_tests_complex_ref,
+            \@all_tests,
         );
-        like($stderr, qr/No tests exist for configure step $not_expected/,
-            "Warning about step class lacking test captured");
-    }
+    is( scalar(@$steps_tests_ref), scalar(@tests_expected),
+        "Got expected number of existing steps" );
+    is( scalar(@$steps_lacking_tests_ref), scalar(@not_expected),
+        "Got expected number of missing steps" );
+    is( $steps_lacking_tests_ref->[0], $not_expected[0],
+        "Got expected missing step $not_expected[0]" );
+
     ok( chdir $cwd, "Able to change back to starting directory");
 }
 


More information about the parrot-commits mailing list