tagged release 0.6.4
[parrot.git] / t / steps / auto_fink-09.t
blobb778839788351a8e1b3f2643e59bc9fc97518aaa
1 #! perl
2 # Copyright (C) 2007, The Perl Foundation.
3 # $Id$
4 # auto_fink-09.t
6 use strict;
7 use warnings;
8 use Test::More;
9 plan( skip_all => 'Fink is Darwin only' ) unless $^O =~ /darwin/;
10 plan( tests => 12 );
11 use Carp;
12 use File::Temp;
13 use lib qw( lib t/configure/testlib );
14 use_ok('config::init::defaults');
15 use_ok('config::auto::fink');
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     argv            => [ q{--verbose} ],
23     mode            => q{configure},
24 } );
26 my $conf = Parrot::Configure->new();
28 test_step_thru_runstep($conf, q{init::defaults}, $args);
30 my ($task, $step_name, $step, $ret);
31 my $pkg = q{auto::fink};
33 $conf->add_steps($pkg);
34 $conf->options->set(%{$args});
35 $task = $conf->steps->[-1];
36 $step_name   = $task->step;
38 $step = $step_name->new();
39 ok(defined $step, "$step_name constructor returned defined value");
40 isa_ok($step, $step_name);
43     # mock Fink config file with non-existent Basepath
44     my $tfile = File::Temp->new();
45     open my $fh, ">", $tfile
46         or croak "Unable to open temporary file for writing";
47     print $fh "Basepath: /my/phony/directory\n";
48     close $fh or croak "Unable to close temporary file after writing";
49     $step->{fink_conf} = $tfile;
51     my ($rv, $stdout);
52     capture(
53         sub { $rv = $step->runstep($conf); },
54         \$stdout,
55     );
56     ok(! defined $rv,
57         "runstep() returned undef due to unlocateable Fink directories");
58     is($step->result(), q{failed},
59         "Got expected result for unlocateable Fink directories");
60     like($stdout,
61         qr/Could not locate Fink directories/,
62         "Got expected verbose output for unlocateable Fink directories");
65 pass("Completed all tests in $0");
67 ################### DOCUMENTATION ###################
69 =head1 NAME
71 auto_fink-09.t - test config::auto::fink
73 =head1 SYNOPSIS
75     % prove t/steps/auto_fink-09.t
77 =head1 DESCRIPTION
79 The files in this directory test functionality used by F<Configure.pl>.
81 The tests in this file test config::auto::fink in the case where the one or
82 more of the Fink directories cannot be located.
84 =head1 AUTHOR
86 James E Keenan
88 =head1 SEE ALSO
90 config::auto::fink, F<Configure.pl>.
92 =cut
94 # Local Variables:
95 #   mode: cperl
96 #   cperl-indent-level: 4
97 #   fill-column: 100
98 # End:
99 # vim: expandtab shiftwidth=4: