Author: jkeenan
Date: Mon Oct 1 18:16:43 2007
New Revision: 21729
Added:
branches/reconfigure/t/configure/046-inter.t (contents, props changed)
branches/reconfigure/t/configure/047-inter.t (contents, props changed)
Modified:
branches/reconfigure/MANIFEST
Log:
Add two test files to test the code within Parrot::Configure::_run_this_step()
that handles the special case of 'inter::' config steps which have the
capacity to prompt user for input.
Modified: branches/reconfigure/MANIFEST
==============================================================================
--- branches/reconfigure/MANIFEST (original)
+++ branches/reconfigure/MANIFEST Mon Oct 1 18:16:43 2007
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Mon Oct 1 01:31:02 2007 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Tue Oct 2 01:12:01 2007 UT
#
# See tools/dev/install_files.pl for documentation on the
# format of this file.
@@ -2957,6 +2957,8 @@
t/configure/043-fatal_step.t []
t/configure/044-fatal_step.t []
t/configure/045-fatal_step.t []
+t/configure/046-inter.t []
+t/configure/047-inter.t []
t/configure/101-init_manifest.01.t []
t/configure/101-init_manifest.02.t []
t/configure/102-init_defaults.01.t []
Added: branches/reconfigure/t/configure/046-inter.t
==============================================================================
--- (empty file)
+++ branches/reconfigure/t/configure/046-inter.t Mon Oct 1 18:16:43 2007
@@ -0,0 +1,90 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 046-inter.t
+
+use strict;
+use warnings;
+use Test::More tests => 11;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('inter::theta');
+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 => [],
+ 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 ( $task, $step_name, @step_params, $step, $ret );
+my $pkg = q{inter::theta};
+
+$conf->add_steps($pkg);
+$conf->options->set( %{$args} );
+
+$task = $conf->steps->[0];
+$step_name = $task->step;
[EMAIL PROTECTED] = @{ $task->params };
+
+$step = $step_name->new();
+ok( defined $step, "$step_name constructor returned defined value" );
+isa_ok( $step, $step_name );
+ok( $step->description(), "$step_name has description" );
+my ( @prompts, $object );
[EMAIL PROTECTED] = (q{n});
+$object = tie *STDIN, 'Tie::Filehandle::Preempt::Stdin', @prompts;
+can_ok( 'Tie::Filehandle::Preempt::Stdin', ('READLINE') );
+isa_ok( $object, 'Tie::Filehandle::Preempt::Stdin' );
+
+$ret = $step->runstep($conf);
+ok( defined $ret, "$step_name runstep() returned defined value" );
+
+$object = undef;
+untie *STDIN;
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+046-inter.t - test Parrot::Configure::_run_this_step() with regard to
configuration steps that prompt for user input
+
+=head1 SYNOPSIS
+
+ % prove t/configure/046-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:
+
Added: branches/reconfigure/t/configure/047-inter.t
==============================================================================
--- (empty file)
+++ branches/reconfigure/t/configure/047-inter.t Mon Oct 1 18:16:43 2007
@@ -0,0 +1,98 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 047-inter.t
+
+use strict;
+use warnings;
+use Test::More tests => 12;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('inter::theta');
+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 ( $task, $step_name, @step_params, $step, $ret );
+my $pkg = q{inter::theta};
+
+$conf->add_steps($pkg);
+$conf->options->set( %{$args} );
+
+$task = $conf->steps->[0];
+$step_name = $task->step;
[EMAIL PROTECTED] = @{ $task->params };
+
+$step = $step_name->new();
+ok( defined $step, "$step_name constructor returned defined value" );
+isa_ok( $step, $step_name );
+ok( $step->description(), "$step_name has description" );
+my ( @prompts, $object );
[EMAIL PROTECTED] = (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 $tie_out = tie *STDOUT, "Parrot::IO::Capture::Mini"
+ or croak "Unable to tie";
+ $ret = $step->runstep($conf);
+ ok( defined $ret, "$step_name runstep() returned defined value" );
+ my $line = $tie_out->READLINE;
+ my $question = 'Will Perl 6 be out before Christmas?';
+ like($line, qr/$question/, "got expected prompt");
+}
+
+$object = undef;
+untie *STDIN;
+untie *STDOUT;
+
+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:
+