2 # Copyright (C) 2007, Parrot Foundation.
8 use Test::More tests => 14;
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(
17 test_step_thru_runstep
18 test_step_constructor_and_description
20 use Tie::Filehandle::Preempt::Stdin;
21 use IO::CaptureOutput qw | capture |;
23 ########## ask; maintainer; prompt flex ##########
25 my ($args, $step_list_ref) = process_options(
27 argv => [ q{--ask}, q{--maintainer} ],
31 my $conf = Parrot::Configure->new();
33 test_step_thru_runstep( $conf, q{init::defaults}, $args );
35 my @prompts = q{flex};
36 my $object = tie *STDIN, 'Tie::Filehandle::Preempt::Stdin', @prompts;
37 can_ok( 'Tie::Filehandle::Preempt::Stdin', ('READLINE') );
38 isa_ok( $object, 'Tie::Filehandle::Preempt::Stdin' );
40 my $pkg = q{inter::lex};
42 $conf->add_steps($pkg);
44 my $serialized = $conf->pcfreeze();
46 $conf->options->set( %{$args} );
47 my $step = test_step_constructor_and_description($conf);
52 capture ( sub {$rv = $step->runstep($conf)}, \$stdout);
53 my $possible_results = qr/^(
54 no\slex\sprogram\swas\sfound
55 | lex\sprogram\sdoes\snot\sexist\sor\sdoes\snot\sunderstand\s--version
56 | could\snot\sunderstand\sflex\sversion\srequirement
57 | found\sflex\sversion.*?but\sat\sleast.*?is\srequired
60 my @dump_msg = ( Dumper( $step->result() ) =~ /'(.*?)'/ );
61 like( $step->result(), $possible_results,
62 "Response to prompt led to acceptable result: " . $dump_msg[0] );
63 if ( $dump_msg[0] eq q{no lex program was found} ) {
64 ok( !$stdout, "No lex program => no prompts" );
67 ok( $stdout, "prompts were captured" );
71 $conf->replenish($serialized);
73 pass("Completed all tests in $0");
75 ################### DOCUMENTATION ###################
79 inter/lex-03.t - test inter::lex
83 % prove t/steps/inter/lex-03.t
87 The files in this directory test functionality used by F<Configure.pl>.
89 The tests in this file test inter::lex. In
90 this test the C<--ask>, C<--maintainer> and C<--lex=flex> options are
99 config::inter::lex, F<Configure.pl>.
105 # cperl-indent-level: 4
108 # vim: expandtab shiftwidth=4: