2 # Copyright (C) 2007, Parrot Foundation.
8 use Test::More tests => 9;
11 use lib qw( lib t/configure/testlib );
12 use_ok('config::inter::lex');
13 use Parrot::Configure::Options qw( process_options );
14 use Parrot::Configure::Step::Test;
15 use Parrot::Configure::Test qw(
16 test_step_constructor_and_description
18 use Tie::Filehandle::Preempt::Stdin;
19 use IO::CaptureOutput qw | capture |;
21 ########## ask; maintainer; prompt flex ##########
23 my ($args, $step_list_ref) = process_options(
25 argv => [ q{--ask}, q{--maintainer} ],
30 my $conf = Parrot::Configure::Step::Test->new;
31 $conf->include_config_results( $args );
33 my @prompts = q{flex};
34 my $object = tie *STDIN, 'Tie::Filehandle::Preempt::Stdin', @prompts;
35 can_ok( 'Tie::Filehandle::Preempt::Stdin', ('READLINE') );
36 isa_ok( $object, 'Tie::Filehandle::Preempt::Stdin' );
38 my $pkg = q{inter::lex};
40 $conf->add_steps($pkg);
42 my $serialized = $conf->pcfreeze();
44 $conf->options->set( %{$args} );
45 my $step = test_step_constructor_and_description($conf);
50 capture ( sub {$rv = $step->runstep($conf)}, \$stdout);
51 my $possible_results = qr/^(
52 no\slex\sprogram\swas\sfound
53 | lex\sprogram\sdoes\snot\sexist\sor\sdoes\snot\sunderstand\s--version
54 | could\snot\sunderstand\sflex\sversion\srequirement
55 | found\sflex\sversion.*?but\sat\sleast.*?is\srequired
58 my @dump_msg = ( Dumper( $step->result() ) =~ /'(.*?)'/ );
59 like( $step->result(), $possible_results,
60 "Response to prompt led to acceptable result: " . $dump_msg[0] );
61 if ( $dump_msg[0] eq q{no lex program was found} ) {
62 ok( !$stdout, "No lex program => no prompts" );
65 ok( $stdout, "prompts were captured" );
69 $conf->replenish($serialized);
71 pass("Completed all tests in $0");
73 ################### DOCUMENTATION ###################
77 inter/lex-03.t - test inter::lex
81 % prove t/steps/inter/lex-03.t
85 The files in this directory test functionality used by F<Configure.pl>.
87 The tests in this file test inter::lex. In
88 this test the C<--ask>, C<--maintainer> and C<--lex=flex> options are
97 config::inter::lex, F<Configure.pl>.
103 # cperl-indent-level: 4
106 # vim: expandtab shiftwidth=4: