tagged release 0.6.4
[parrot.git] / t / steps / init_hints-02.t
blob8925cb52aeabdcccefc93cf92a9a6fdb18761625
1 #! perl
2 # Copyright (C) 2007, The Perl Foundation.
3 # $Id$
4 # init_hints-02.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;
56 sub runstep {
57     return 1;
60 END
61     close $FH or croak "Unable to close temp file after writing";
62     unshift( @INC, $tdir );
64     # need to capture the --verbose output,
65     # because the fact that it does not end
66     # in a newline confuses Test::Harness
67     {
68      my $rv;
69      my $stdout;
70      capture ( sub {$rv = $step->runstep($conf)}, \$stdout);
71      ok( $stdout, "verbose output:  hints were captured" );
72      ok( defined $rv, "$step_name runstep() returned defined value" );
73     }
74     unlink $localhints or croak "Unable to delete $localhints";
77 pass("Completed all tests in $0");
79 ################### DOCUMENTATION ###################
81 =head1 NAME
83 init_hints-02.t - test config::init::hints
85 =head1 SYNOPSIS
87     % prove t/steps/init_hints-02.t
89 =head1 DESCRIPTION
91 The files in this directory test functionality used by F<Configure.pl>.
93 The tests in this file test subroutines exported by config::init::hints.
95 =head1 AUTHOR
97 James E Keenan
99 =head1 SEE ALSO
101 config::init::hints, F<Configure.pl>.
103 =cut
105 # Local Variables:
106 #   mode: cperl
107 #   cperl-indent-level: 4
108 #   fill-column: 100
109 # End:
110 # vim: expandtab shiftwidth=4: