[cage] Update release manager guide about committing to trunk near a release, based...
[parrot.git] / t / steps / inter / lex-03.t
blobe356231d7d6070b9d4f8acb6118e476df3fcad13
1 #! perl
2 # Copyright (C) 2007, Parrot Foundation.
3 # $Id$
4 # inter/lex-03.t
6 use strict;
7 use warnings;
8 use Test::More tests =>  14;
9 use Carp;
10 use Data::Dumper;
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(
26     {
27         argv => [ q{--ask}, q{--maintainer} ],
28         mode => q{configure},
29     }
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);
50     my $rv;
51     my $stdout;
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
58       | flex
59     )/x;
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" );
65     }
66     else {
67         ok( $stdout, "prompts were captured" );
68     }
70 $object = undef;
71 $conf->replenish($serialized);
73 pass("Completed all tests in $0");
75 ################### DOCUMENTATION ###################
77 =head1 NAME
79 inter/lex-03.t - test inter::lex
81 =head1 SYNOPSIS
83     % prove t/steps/inter/lex-03.t
85 =head1 DESCRIPTION
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
91 provided.
93 =head1 AUTHOR
95 James E Keenan
97 =head1 SEE ALSO
99 config::inter::lex, F<Configure.pl>.
101 =cut
103 # Local Variables:
104 #   mode: cperl
105 #   cperl-indent-level: 4
106 #   fill-column: 100
107 # End:
108 # vim: expandtab shiftwidth=4: