Author: jkeenan
Date: Sat Jul 19 19:18:35 2008
New Revision: 29624

Removed:
   branches/parallel/t/steps/inter_yacc-02.t
   branches/parallel/t/steps/inter_yacc-04.t
   branches/parallel/t/steps/inter_yacc-05.t
Modified:
   branches/parallel/MANIFEST
   branches/parallel/t/steps/inter_yacc-01.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:18:35 2008
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Sun Jul 20 00:44:24 2008 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Sun Jul 20 02:18:25 2008 UT
 #
 # See tools/dev/install_files.pl for documentation on the
 # format of this file.
@@ -3677,10 +3677,7 @@
 t/steps/inter_shlibs-01.t                                   []
 t/steps/inter_types-01.t                                    []
 t/steps/inter_yacc-01.t                                     []
-t/steps/inter_yacc-02.t                                     []
 t/steps/inter_yacc-03.t                                     []
-t/steps/inter_yacc-04.t                                     []
-t/steps/inter_yacc-05.t                                     []
 t/stm/basic.t                                               []
 t/stm/basic_mt.t                                            []
 t/stm/llqueue.t                                             []

Modified: branches/parallel/t/steps/inter_yacc-01.t
==============================================================================
--- branches/parallel/t/steps/inter_yacc-01.t   (original)
+++ branches/parallel/t/steps/inter_yacc-01.t   Sat Jul 19 19:18:35 2008
@@ -5,14 +5,23 @@
 
 use strict;
 use warnings;
-use Test::More tests => 12;
+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::yacc');
 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,21 +34,113 @@
 
 test_step_thru_runstep( $conf, q{init::defaults}, $args );
 
-my ( $task, $step_name, $step, $ret );
 my $pkg = q{inter::yacc};
 
 $conf->add_steps($pkg);
+
+my $serialized = $conf->pcfreeze();
+
 $conf->options->set( %{$args} );
-$task        = $conf->steps->[-1];
-$step_name   = $task->step;
+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 step
+$step->set_result(q{});
 
-$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" );
+$conf->replenish($serialized);
+
+########## ask; maintainer; $ENV{YACC}  ##########
+
+$ENV{YACC} = 'foobar';
+$args = process_options(
+    {
+        argv => [ q{--ask}, q{--maintainer} ],
+        mode => q{configure},
+    }
+);
+$conf->options->set( %{$args} );
+$step = test_step_constructor_and_description($conf);
 $ret = $step->runstep($conf);
-ok( defined $ret, "$step_name runstep() returned defined value" );
-is( $step->result(), q{skipped}, "Step was skipped as expected; no 
'--maintainer' option" );
+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 step
+$ENV{YACC} = undef;
+$step->set_result(q{});
+
+$conf->replenish($serialized);
+
+########## ask; maintainer; yacc=bison  ##########
+
+$args = process_options(
+    {
+        argv => [ q{--ask}, q{--maintainer}, q{--yacc=bison} ],
+        mode => q{configure},
+    }
+);
+$conf->options->set( %{$args} );
+$step = test_step_constructor_and_description($conf);
+my ( @prompts, $object );
[EMAIL PROTECTED] = 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' );
+$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 step
+$step->set_result(q{});
[EMAIL PROTECTED] = ();
+
+$conf->replenish($serialized);
+
+########## ask; maintainer; ##########
+
+$args = process_options(
+    {
+        argv => [ q{--ask}, q{--maintainer} ],
+        mode => q{configure},
+    }
+);
+$conf->options->set( %{$args} );
+$step = test_step_constructor_and_description($conf);
[EMAIL PROTECTED] = q{bison};
+$object = tie *STDIN, 'Tie::Filehandle::Preempt::Stdin', @prompts;
+can_ok( 'Tie::Filehandle::Preempt::Stdin', ('READLINE') );
+isa_ok( $object, 'Tie::Filehandle::Preempt::Stdin' );
+{
+    my $rv;
+    my $stdout;
+    capture ( sub {$rv = $step->runstep($conf)}, \$stdout);
+    my $possible_results = qr/^(
+        no\syacc\sprogram\swas\sfound
+      | yacc\sprogram\sdoes\snot\sexist\sor\sdoes\snot\sunderstand\s--version
+      | could\snot\sunderstand\sbison\sversion\srequirement
+      | found\sbison\sversion.*?but\sat\sleast.*?is\srequired
+      | bison
+    )/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 yacc program was found} ) {
+        ok( !$stdout, "No yacc program => no prompts" );
+    }
+    else {
+        ok( $stdout, "prompts were captured" );
+    }
+}
+$object = undef;
+untie *STDIN;
+# re-set for next step
+$step->set_result(q{});
[EMAIL PROTECTED] = ();
+
 
 pass("Completed all tests in $0");
 

Reply via email to