tagged release 0.6.4
[parrot.git] / t / steps / init_hints-03.t
blobe2616597a0b63031adbcb945b1d177c231f25114
1 #! perl
2 # Copyright (C) 2007, The Perl Foundation.
3 # $Id$
4 # init_hints-03.t
6 use strict;
7 use warnings;
8 use Test::More tests =>  11;
9 use Carp;
10 use Cwd;
11 use File::Path ();
12 use File::Temp qw(tempdir);
13 use lib qw( lib t/configure/testlib );
14 use_ok('config::init::defaults');
15 use_ok('config::init::hints');
16 use Parrot::Configure;
17 use Parrot::Configure::Options qw( process_options );
18 use Parrot::Configure::Test qw( test_step_thru_runstep);
19 use IO::CaptureOutput qw | capture |;
21 my $args = process_options(
22     {
23         argv => [q{--verbose}],
24         mode => q{configure},
25     }
28 my $conf = Parrot::Configure->new;
30 test_step_thru_runstep( $conf, q{init::defaults}, $args );
32 my ( $task, $step_name, $step, $ret );
33 my $pkg = q{init::hints};
35 $conf->add_steps($pkg);
36 $conf->options->set( %{$args} );
38 $task        = $conf->steps->[-1];
39 $step_name   = $task->step;
41 $step = $step_name->new();
42 ok( defined $step, "$step_name constructor returned defined value" );
43 isa_ok( $step, $step_name );
45 my $cwd = cwd();
47     my $tdir = tempdir( CLEANUP => 1 );
48     File::Path::mkpath(qq{$tdir/init/hints})
49         or croak "Unable to create directory for local hints";
50     my $localhints = qq{$tdir/init/hints/local.pm};
51     open my $FH, '>', $localhints
52         or croak "Unable to open temp file for writing";
53     print $FH <<END;
54 package init::hints::local;
55 use strict;
57 END
58     close $FH or croak "Unable to close temp file after writing";
59     unshift( @INC, $tdir );
61     # need to capture the --verbose output,
62     # because the fact that it does not end
63     # in a newline confuses Test::Harness
64     {
65      my $rv;
66      my $stdout;
67      capture ( sub {$rv = $step->runstep($conf)}, \$stdout);
68      ok( $stdout, "verbose output:  hints were captured" );
69      ok( defined $rv, "$step_name runstep() returned defined va lue" );
70     }
71     unlink $localhints or croak "Unable to delete $localhints";
74 pass("Completed all tests in $0");
76 ################### DOCUMENTATION ###################
78 =head1 NAME
80 init_hints-03.t - test config::init::hints
82 =head1 SYNOPSIS
84     % prove t/steps/init_hints-03.t
86 =head1 DESCRIPTION
88 The files in this directory test functionality used by F<Configure.pl>.
90 The tests in this file test subroutines exported by config::init::hints.
92 =head1 AUTHOR
94 James E Keenan
96 =head1 SEE ALSO
98 config::init::hints, F<Configure.pl>.
100 =cut
102 # Local Variables:
103 #   mode: cperl
104 #   cperl-indent-level: 4
105 #   fill-column: 100
106 # End:
107 # vim: expandtab shiftwidth=4: