perl.cvs.parrot
[Top] [All Lists]

[svn:parrot] r29627 - in branches/parallel: . t/steps

Subject: [svn:parrot] r29627 - in branches/parallel: . t/steps
From:
Date: Sat, 19 Jul 2008 19:53:58 -0700 PDT
Newsgroups: perl.cvs.parrot

Author: jkeenan
Date: Sat Jul 19 19:53:58 2008
New Revision: 29627

Removed:
   branches/parallel/t/steps/inter_lex-05.t
Modified:
   branches/parallel/MANIFEST
   branches/parallel/t/steps/inter_lex-01.t
   branches/parallel/t/steps/inter_lex-03.t

Log:
Consolidate multiple test files per configuration step into a single file.


Modified: branches/parallel/MANIFEST
==============================================================================
--- branches/parallel/MANIFEST  (original)
+++ branches/parallel/MANIFEST  Sat Jul 19 19:53:58 2008
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Sun Jul 20 02:20:58 2008 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Sun Jul 20 02:53:25 2008 UT
 #
 # See tools/dev/install_files.pl for documentation on the
 # format of this file.
@@ -3670,7 +3670,6 @@
 t/steps/inter_lex-01.t                                      []
 t/steps/inter_lex-02.t                                      []
 t/steps/inter_lex-03.t                                      []
-t/steps/inter_lex-05.t                                      []
 t/steps/inter_libparrot-01.t                                []
 t/steps/inter_make-01.t                                     []
 t/steps/inter_progs-01.t                                    []

Modified: branches/parallel/t/steps/inter_lex-01.t
==============================================================================
--- branches/parallel/t/steps/inter_lex-01.t    (original)
+++ branches/parallel/t/steps/inter_lex-01.t    Sat Jul 19 19:53:58 2008
@@ -5,14 +5,23 @@
 
 use strict;
 use warnings;
-use Test::More tests => 16;
+use Test::More tests => 31;
 use Carp;
+use Data::Dumper;
 use lib qw( lib t/configure/testlib );
 use_ok('config::init::defaults');
 use_ok('config::inter::lex');
 use Parrot::Configure;
 use Parrot::Configure::Options qw( process_options );
-use Parrot::Configure::Test qw( test_step_thru_runstep);
+use Parrot::Configure::Test qw(
+    test_step_thru_runstep
+    rerun_defaults_for_testing
+    test_step_constructor_and_description
+);
+use Tie::Filehandle::Preempt::Stdin;
+use IO::CaptureOutput qw | capture |;
+
+########## ask ##########
 
 my $args = process_options(
     {
@@ -25,7 +34,6 @@
 
 test_step_thru_runstep( $conf, q{init::defaults}, $args );
 
-my ( $task, $step_name, $step, $ret );
 my $pkg = q{inter::lex};
 
 $conf->add_steps($pkg);
@@ -33,19 +41,17 @@
 my $serialized = $conf->pcfreeze();
 
 $conf->options->set( %{$args} );
-$task        = $conf->steps->[-1];
-$step_name   = $task->step;
-
-$step = $step_name->new();
-ok( defined $step, "$step_name constructor returned defined value" );
-isa_ok( $step, $step_name );
-ok( $step->description(), "$step_name has description" );
-$ret = $step->runstep($conf);
-ok( defined $ret, "$step_name runstep() returned defined value" );
+my $step = test_step_constructor_and_description($conf);
+my $ret = $step->runstep($conf);
+ok( defined $ret, "runstep() returned defined value" );
 is( $step->result(), q{skipped}, "Step was skipped as expected; no 
'--maintainer' option" );
+# re-set for next test
+$step->set_result(q{});
 
 $conf->replenish($serialized);
 
+########## ask; maintainer; $ENV{LEX} ##########
+
 $ENV{LEX} = 'foobar';
 
 $args = process_options(
@@ -56,19 +62,81 @@
 );
 
 $conf->options->set( %{$args} );
-
-$task        = $conf->steps->[-1];
-$step_name   = $task->step;
-
-$step = $step_name->new();
-ok( defined $step, "$step_name constructor returned defined value" );
-isa_ok( $step, $step_name );
-
+$step = test_step_constructor_and_description($conf);
 $ret = $step->runstep($conf);
-ok( defined $ret, "$step_name runstep() returned defined value" );
+ok( defined $ret, "runstep() returned defined value" );
 my $result_expected = q{user defined};
 is( $step->result(), $result_expected,
     "Result was $result_expected because environmental variable was set" );
+# re-set for next test
+$ENV{LEX} = undef;
+$step->set_result(q{});
+
+$conf->replenish($serialized);
+
+########## ask; maintainer; lex=flex ##########
+
+$args = process_options(
+    {
+        argv => [ q{--ask}, q{--maintainer}, q{--lex=flex} ],
+        mode => q{configure},
+    }
+);
+my ( @prompts, $object, @entered );
+@prompts = map { q{foo_} . $_ } qw| alpha |;
+
+$object = tie *STDIN, 'Tie::Filehandle::Preempt::Stdin', @prompts;
+can_ok( 'Tie::Filehandle::Preempt::Stdin', ('READLINE') );
+isa_ok( $object, 'Tie::Filehandle::Preempt::Stdin' );
+$conf->options->set( %{$args} );
+$step = test_step_constructor_and_description($conf);
+$ret = $step->runstep($conf);
+ok( defined $ret, "runstep() returned defined value" );
+$result_expected = q{user defined};
+is( $step->result(), $result_expected, "Result was $result_expected" );
+$object = undef;
+untie *STDIN;
+# re-set for next test
+$step->set_result(q{});
+
+$conf->replenish($serialized);
+
+########## ask; maintainer ##########
+
+$args = process_options(
+    {
+        argv => [ q{--ask}, q{--maintainer} ],
+        mode => q{configure},
+    }
+);
+@prompts = q{flex};
+$object = tie *STDIN, 'Tie::Filehandle::Preempt::Stdin', @prompts;
+can_ok( 'Tie::Filehandle::Preempt::Stdin', ('READLINE') );
+isa_ok( $object, 'Tie::Filehandle::Preempt::Stdin' );
+$conf->options->set( %{$args} );
+$step = test_step_constructor_and_description($conf);
+{
+    my $rv;
+    my $stdout;
+    capture ( sub {$rv = $step->runstep($conf)}, \$stdout);
+    my $possible_results = qr/^(
+        no\slex\sprogram\swas\sfound
+      | lex\sprogram\sdoes\snot\sexist\sor\sdoes\snot\sunderstand\s--version
+      | could\snot\sunderstand\sflex\sversion\srequirement
+      | found\sflex\sversion.*?but\sat\sleast.*?is\srequired
+      | flex
+    )/x;
+    my @dump_msg = ( Dumper( $step->result() ) =~ /'(.*?)'/ );
+    like( $step->result(), $possible_results,
+        "Response to prompt led to acceptable result:  " . $dump_msg[0] );
+    if ( $dump_msg[0] eq q{no lex program was found} ) {
+        ok( !$stdout, "No lex program => no prompts" );
+    }
+    else {
+        ok( $stdout, "prompts were captured" );
+    }
+}
+$object = undef;
 
 pass("Completed all tests in $0");
 

Modified: branches/parallel/t/steps/inter_lex-03.t
==============================================================================
--- branches/parallel/t/steps/inter_lex-03.t    (original)
+++ branches/parallel/t/steps/inter_lex-03.t    Sat Jul 19 19:53:58 2008
@@ -5,7 +5,7 @@
 
 use strict;
 use warnings;
-use Test::More tests =>  19;
+use Test::More tests =>  14;
 use Carp;
 use Data::Dumper;
 use lib qw( lib t/configure/testlib );
@@ -13,29 +13,29 @@
 use_ok('config::inter::lex');
 use Parrot::Configure;
 use Parrot::Configure::Options qw( process_options );
-use Parrot::Configure::Test qw( test_step_thru_runstep);
+use Parrot::Configure::Test qw(
+    test_step_thru_runstep
+    rerun_defaults_for_testing
+    test_step_constructor_and_description
+);
 use Tie::Filehandle::Preempt::Stdin;
 use IO::CaptureOutput qw | capture |;
 
 my $args = process_options(
     {
-        argv => [ q{--ask}, q{--maintainer}, q{--lex=flex} ],
+        argv => [ q{--ask}, q{--maintainer} ],
         mode => q{configure},
     }
 );
-
 my $conf = Parrot::Configure->new();
 
 test_step_thru_runstep( $conf, q{init::defaults}, $args );
 
-my ( @prompts, $object, @entered );
-@prompts = map { q{foo_} . $_ } qw| alpha |;
-
-$object = tie *STDIN, 'Tie::Filehandle::Preempt::Stdin', @prompts;
+my @prompts = q{flex};
+my $object = tie *STDIN, 'Tie::Filehandle::Preempt::Stdin', @prompts;
 can_ok( 'Tie::Filehandle::Preempt::Stdin', ('READLINE') );
 isa_ok( $object, 'Tie::Filehandle::Preempt::Stdin' );
 
-my ( $task, $step_name, $step, $ret );
 my $pkg = q{inter::lex};
 
 $conf->add_steps($pkg);
@@ -43,41 +43,7 @@
 my $serialized = $conf->pcfreeze();
 
 $conf->options->set( %{$args} );
-
-$task        = $conf->steps->[-1];
-$step_name   = $task->step;
-
-$step = $step_name->new();
-ok( defined $step, "$step_name constructor returned defined value" );
-isa_ok( $step, $step_name );
-
-$ret = $step->runstep($conf);
-ok( defined $ret, "$step_name runstep() returned defined value" );
-my $result_expected = q{user defined};
-is( $step->result(), $result_expected, "Result was $result_expected" );
-
-$object = undef;
-untie *STDIN;
-
-$args = process_options(
-    {
-        argv => [ q{--ask}, q{--maintainer} ],
-        mode => q{configure},
-    }
-);
-
-@prompts = q{flex};
-$object = tie *STDIN, 'Tie::Filehandle::Preempt::Stdin', @prompts;
-can_ok( 'Tie::Filehandle::Preempt::Stdin', ('READLINE') );
-isa_ok( $object, 'Tie::Filehandle::Preempt::Stdin' );
-
-$task        = $conf->steps->[-1];
-$step_name   = $task->step;
-
-$step = $step_name->new();
-ok( defined $step, "$step_name constructor returned defined value" );
-isa_ok( $step, $step_name );
-
+my $step = test_step_constructor_and_description($conf);
 
 TODO: {
     local $TODO = 'some problem with testing interactive configuration steps';
@@ -103,7 +69,6 @@
     }
 }
 }
-
 $object = undef;
 $conf->replenish($serialized);
 

<Prev in Thread] Current Thread [Next in Thread>
  • [svn:parrot] r29627 - in branches/parallel: . t/steps, jkeenan <=