Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tag: RELEASE_0_5_0
Fetching contributors…

Cannot retrieve contributors at this time

113 lines (87 sloc) 2.881 kb
#! perl
# Copyright (C) 2007, The Perl Foundation.
# $Id$
# 047-inter.t
use strict;
use warnings;
use Test::More tests => 15;
use Carp;
use lib qw( lib t/configure/testlib );
use Parrot::Configure;
use Parrot::Configure::Options qw( process_options );
use Parrot::IO::Capture::Mini;
use Tie::Filehandle::Preempt::Stdin;
$| = 1;
is( $|, 1, "output autoflush is set" );
my $args = process_options(
{
argv => [ q{--ask} ],
mode => q{configure},
}
);
ok( defined $args, "process_options returned successfully" );
my %args = %$args;
my $conf = Parrot::Configure->new;
ok( defined $conf, "Parrot::Configure->new() returned okay" );
my $step = q{inter::theta};
my $description = 'Determining if your computer does theta';
$conf->add_steps($step);
my @confsteps = @{ $conf->steps };
isnt( scalar @confsteps, 0,
"Parrot::Configure object 'steps' key holds non-empty array reference" );
is( scalar @confsteps, 1, "Parrot::Configure object 'steps' key holds ref to 1-element array" );
my $nontaskcount = 0;
foreach my $k (@confsteps) {
$nontaskcount++ unless $k->isa("Parrot::Configure::Task");
}
is( $nontaskcount, 0, "Each step is a Parrot::Configure::Task object" );
is( $confsteps[0]->step, $step, "'step' element of Parrot::Configure::Task struct identified" );
is( ref( $confsteps[0]->params ),
'ARRAY', "'params' element of Parrot::Configure::Task struct is array ref" );
ok( !ref( $confsteps[0]->object ),
"'object' element of Parrot::Configure::Task struct is not yet a ref" );
$conf->options->set(%args);
is( $conf->options->{c}->{debugging},
1, "command-line option '--debugging' has been stored in object" );
my ( @prompts, $object );
@prompts = (q{n});
$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 ( $tie, @lines );
{
$tie = tie *STDOUT, "Parrot::IO::Capture::Mini"
or croak "Unable to tie";
$rv = $conf->runsteps;
@lines = $tie->READLINE;
undef $tie;
}
ok($rv, "runsteps() returned true value");
my $bigmsg = join q{}, @lines;
like(
$bigmsg,
qr/$description\.\.\./s,
"Got STDOUT message expected upon running $step"
);
$object = undef;
untie *STDIN;
pass("Completed all tests in $0");
################### DOCUMENTATION ###################
=head1 NAME
047-inter.t - test Parrot::Configure::_run_this_step() with regard to configuration steps that prompt for user input
=head1 SYNOPSIS
% prove t/configure/047-inter.t
=head1 DESCRIPTION
The files in this directory test functionality used by F<Configure.pl>.
=head1 AUTHOR
James E Keenan
=head1 SEE ALSO
Parrot::Configure, F<Configure.pl>.
=cut
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4:
Jump to Line
Something went wrong with that request. Please try again.