2 # Copyright (C) 2007, The Perl Foundation.
9 use Test::More tests => 13;
11 use lib qw( lib t/configure/testlib );
12 use_ok('config::init::defaults');
13 use_ok('config::inter::lex');
14 use Parrot::Configure;
15 use Parrot::Configure::Options qw( process_options );
16 use Parrot::Configure::Test qw( test_step_thru_runstep);
17 use Tie::Filehandle::Preempt::Stdin;
18 use IO::CaptureOutput qw | capture |;
20 my $args = process_options(
22 argv => [ q{--ask}, q{--maintainer} ],
27 my $conf = Parrot::Configure->new();
29 test_step_thru_runstep( $conf, q{init::defaults}, $args );
31 my ( @prompts, $object, @entered );
33 $object = tie *STDIN, 'Tie::Filehandle::Preempt::Stdin', @prompts;
34 can_ok( 'Tie::Filehandle::Preempt::Stdin', ('READLINE') );
35 isa_ok( $object, 'Tie::Filehandle::Preempt::Stdin' );
37 my ( $task, $step_name, $step, $ret );
38 my $pkg = q{inter::lex};
40 $conf->add_steps($pkg);
41 $conf->options->set( %{$args} );
43 $task = $conf->steps->[-1];
44 $step_name = $task->step;
46 $step = $step_name->new();
47 ok( defined $step, "$step_name constructor returned defined value" );
48 isa_ok( $step, $step_name );
54 capture ( sub {$rv = $step->runstep($conf)}, \$stdout);
55 my $possible_results = qr/^(
56 no\slex\sprogram\swas\sfound
57 | lex\sprogram\sdoes\snot\sexist\sor\sdoes\snot\sunderstand\s--version
58 | could\snot\sunderstand\sflex\sversion\srequirement
59 | found\sflex\sversion.*?but\sat\sleast.*?is\srequired
62 my @dump_msg = ( Dumper( $step->result() ) =~ /'(.*?)'/ );
63 like( $step->result(), $possible_results,
64 "Response to prompt led to acceptable result: " . $dump_msg[0] );
65 if ( $dump_msg[0] eq q{no lex program was found} ) {
66 ok( !$stdout, "No lex program => no prompts" );
69 ok( $stdout, "prompts were captured" );
75 pass("Completed all tests in $0");
77 ################### DOCUMENTATION ###################
81 inter_lex-05.t - test config::inter::lex
85 % prove t/steps/inter_lex-05.t
89 The files in this directory test functionality used by F<Configure.pl>.
91 The tests in this file test subroutines exported by config::inter::lex.
99 config::inter::lex, F<Configure.pl>.
105 # cperl-indent-level: 4
108 # vim: expandtab shiftwidth=4: