Author: jkeenan
Date: Sun Apr 15 10:54:33 2007
New Revision: 18227

Added:
   branches/reconfigure/t/configure/12-verbose.t   (contents, props changed)
   branches/reconfigure/t/configure/testlib/init/beta.pm

Log:
1.  Added another module for use only in testing configuration tools:
t/configure/testlib/init/beta.pm.  This module holds a configuration package,
init::beta, which has an action taken when verbose is set.
undefined.
2.  Added t/configure/12-verbose.t to test C<--verbose> command-line argument
with a step that has an action that occurs when verbose is defined.


Added: branches/reconfigure/t/configure/12-verbose.t
==============================================================================
--- (empty file)
+++ branches/reconfigure/t/configure/12-verbose.t       Sun Apr 15 10:54:33 2007
@@ -0,0 +1,124 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 12-verbose.t
+
+use strict;
+use warnings;
+
+BEGIN {
+    use FindBin qw($Bin);
+    use Cwd qw(cwd realpath);
+    realpath($Bin) =~ m{^(.*\/parrot)\/[^/]*\/[^/]*\/[^/]*$};
+    our $topdir = $1;
+    if ( defined $topdir ) {
+        print "\nOK:  Parrot top directory located\n";
+    }
+    else {
+        $topdir = realpath($Bin) . "/../..";
+    }
+    unshift @INC, qq{$topdir/lib};
+}
+use Test::More tests => 14;
+use Carp;
+#use Data::Dumper;
+#$Data::Dumper::Indent=1;
+use Parrot::BuildUtil;
+use Parrot::Configure;
+use Parrot::Configure::Options qw( process_options );
+use Parrot::IO::Capture::Mini;
+use lib ("t/configure/testlib");
+
+my $parrot_version = Parrot::BuildUtil::parrot_version();
+like($parrot_version, qr/\d+\.\d+\.\d+/,
+    "Parrot version is in 3-part format");
+
+$| = 1;
+is($|, 1, "output autoflush is set");
+
+my $args = process_options( {
+    argv            => [ q{--verbose} ],
+    script          => $0,
+    parrot_version  => $parrot_version,
+    svnid           => '$Id$',
+} );
+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{init::beta};
+my $description = 'Determining if your computer does beta';
+
+$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 $rv;
+my ($tie, @lines);
+{
+    $tie = tie *STDOUT, "Parrot::IO::Capture::Mini"
+        or croak "Unable to tie";
+    $rv = $conf->runsteps;
+    @lines = $tie->READLINE;
+}
+ok($rv, "runsteps successfully ran $step");
+my $bigmsg = join q{}, @lines;
+like($bigmsg,
+    qr/$description\.\.\..*beta is verbose.*You've got beta.*done\./s, #'
+    "Got message expected upon running $step");
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+12-verbose.t - test the C<--verbose> command-line argument
+
+=head1 SYNOPSIS
+
+    % prove t/configure/components/12-verbose.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file examine what happens when you configure with
+C<--verbose>.
+
+=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/testlib/init/beta.pm
==============================================================================
--- (empty file)
+++ branches/reconfigure/t/configure/testlib/init/beta.pm       Sun Apr 15 
10:54:33 2007
@@ -0,0 +1,37 @@
+# Copyright (C) 2001-2003, The Perl Foundation.
+# $Id: beta.pm 18226 2007-04-15 17:23:44Z jkeenan $
+
+=head1 NAME
+
+t/configure/testlib/init/beta.pm - Module used in configuration tests
+
+=cut
+
+package init::beta;
+use strict;
+use warnings;
+use vars qw($description @args);
+
+use base qw(Parrot::Configure::Step::Base);
+
+use Parrot::Configure::Step;
+
+$description = 'Determining if your computer does beta';
[EMAIL PROTECTED] = qw( verbose );
+
+sub runstep {
+    my ( $self, $conf ) = @_;
+    my $verbose = $conf->options->get('verbose');
+    print "\nbeta is verbose\n" if $verbose;
+    print "\nYou've got beta\n";
+    return $self;
+}
+
+1;
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:

Reply via email to