Author: jkeenan Date: Thu Jan 3 16:28:56 2008 New Revision: 24517 Added: trunk/config/auto/fink.pm (contents, props changed) trunk/t/configure/113-auto_fink-01.t (contents, props changed) trunk/t/configure/113-auto_fink-02.t (contents, props changed) trunk/t/configure/113-auto_fink-03.t (contents, props changed) trunk/t/configure/113-auto_fink-04.t (contents, props changed) trunk/t/configure/113-auto_fink-05.t (contents, props changed) trunk/t/configure/113-auto_fink-06.t (contents, props changed) trunk/t/configure/113-auto_fink-07.t (contents, props changed) trunk/t/configure/113-auto_fink-08.t (contents, props changed) trunk/t/configure/113-auto_fink-09.t (contents, props changed) Modified: trunk/MANIFEST trunk/config/auto/gdbm.pm trunk/config/auto/gmp.pm trunk/config/auto/readline.pm trunk/lib/Parrot/Configure/Step/List.pm
Log: Applying patch proposed in http://rt.perl.org/rt3/Ticket/Update.html?id=43134. Allow for possibility that on Darwin a user may have installed Fink in a non-standard location and may be compiling with Fink-installable options such as gdbm, gmp and readline. Add new config step class auto::fink and 8 test files; adjust other files as needed. Modified: trunk/MANIFEST ============================================================================== --- trunk/MANIFEST (original) +++ trunk/MANIFEST Thu Jan 3 16:28:56 2008 @@ -1,7 +1,7 @@ # ex: set ro: # $Id$ # -# generated by tools/dev/mk_manifest_and_skip.pl Thu Jan 3 11:01:44 2008 UT +# generated by tools/dev/mk_manifest_and_skip.pl Fri Jan 4 00:22:55 2008 UT # # See tools/dev/install_files.pl for documentation on the # format of this file. @@ -229,6 +229,7 @@ config/auto/env.pm [] config/auto/env/test_setenv.in [] config/auto/env/test_unsetenv.in [] +config/auto/fink.pm [] config/auto/format.pm [] config/auto/funcptr.pm [] config/auto/funcptr/test_c.in [] @@ -1541,10 +1542,12 @@ languages/lolcode/config/makefiles/root.in [lolcode] languages/lolcode/lolcode.pir [lolcode] languages/lolcode/src/builtins/say.pir [lolcode] +languages/lolcode/src/builtins/var_or_function.pir [lolcode] languages/lolcode/src/parser/actions.pm [lolcode] languages/lolcode/src/parser/grammar.pg [lolcode] languages/lolcode/t/00-sanity.t [lolcode] languages/lolcode/t/01-vars.t [lolcode] +languages/lolcode/t/02-functions.t [lolcode] languages/lolcode/t/harness [lolcode] languages/lua/Lua/build.pm [lua] languages/lua/Lua/lexer.pm [lua] @@ -3143,6 +3146,15 @@ t/configure/111-auto_gcc-13.t [] t/configure/112-auto_backtrace-01.t [] t/configure/112-auto_backtrace-02.t [] +t/configure/113-auto_fink-01.t [] +t/configure/113-auto_fink-02.t [] +t/configure/113-auto_fink-03.t [] +t/configure/113-auto_fink-04.t [] +t/configure/113-auto_fink-05.t [] +t/configure/113-auto_fink-06.t [] +t/configure/113-auto_fink-07.t [] +t/configure/113-auto_fink-08.t [] +t/configure/113-auto_fink-09.t [] t/configure/113-auto_msvc-01.t [] t/configure/113-auto_msvc-02.t [] t/configure/113-auto_msvc-03.t [] Added: trunk/config/auto/fink.pm ============================================================================== --- (empty file) +++ trunk/config/auto/fink.pm Thu Jan 3 16:28:56 2008 @@ -0,0 +1,107 @@ +# Copyright (C) 2005-2007, The Perl Foundation. +# $Id$ + +=head1 NAME + +config/auto/fink.pm - Determine Fink location on Darwin + +=head1 DESCRIPTION + +If the operating system is Darwin, this class determines whether and where +Fink is installed. + +=cut + +package auto::fink; + +use strict; +use warnings; + +use base qw(Parrot::Configure::Step); + +use Parrot::Configure::Utils ':auto'; +use Parrot::BuildUtil; + + +sub _init { + my $self = shift; + my %data; + $data{description} = q{Determining Fink location on Darwin}; + $data{args} = [ ]; + $data{result} = q{}; + # Per fink(8), this is location for Fink configuration file, presumably + # regardless of where Fink itself is installed. + $data{fink_conf} = q{/sw/etc/fink.conf}; + return \%data; +} + +sub runstep { + my ( $self, $conf ) = ( shift, shift ); + my $osname = $conf->data->get_p5( 'OSNAME' ); + my $verbose = $conf->options->get( 'verbose' ); + unless ($osname =~ /darwin/) { + print "Operating system is $osname; Fink is Darwin only\n" + if $verbose; + $self->set_result('skipped'); + return 1; + } + # Per fink(8), this is location for Fink configuration file, presumably + # regardless of where Fink itself is installed. + my $fink_conf = $self->{fink_conf}; + unless (-f $fink_conf) { + print "Fink configuration file not located\n" + if $verbose; + $self->set_result('Fink not installed'); + return 1; + } + my $fink_conf_str = Parrot::BuildUtil::slurp_file($fink_conf); + my @lines = split /\n/, $fink_conf_str; + my $fink_base_dir; + while (defined (my $l = shift @lines) ) { + chomp $l; + next unless $l =~ /^Basepath:\s(.*)/; + $fink_base_dir = $1; + last; + } + unless (defined $fink_base_dir) { + print "Fink configuration file defective: no 'Basepath'\n" + if $verbose; + $self->set_result('failed'); + return; + } + my $fink_lib_dir = qq{$fink_base_dir/lib}; + my $fink_include_dir = qq{$fink_base_dir/include}; + my @unlocateables; + foreach my $dir ($fink_base_dir, $fink_lib_dir, $fink_include_dir) { + push @unlocateables, $dir unless (-d $dir); + } + if (@unlocateables) { + print "Could not locate Fink directories: @unlocateables\n" + if $verbose; + $self->set_result('failed'); + return; + } else { + $conf->data->set( + fink_base_dir => $fink_base_dir, + fink_lib_dir => $fink_lib_dir, + fink_include_dir => $fink_include_dir, + ); + $self->set_result('Fink located'); + return 1; + } +} + +1; + +=head1 AUTHOR + +James E Keenan + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Modified: trunk/config/auto/gdbm.pm ============================================================================== --- trunk/config/auto/gdbm.pm (original) +++ trunk/config/auto/gdbm.pm Thu Jan 3 16:28:56 2008 @@ -56,13 +56,13 @@ # On OS X check the presence of the gdbm header in the standard # Fink location. - # RT#43134: Need a more generalized way for finding - # where Fink lives. if ( $osname =~ /darwin/ ) { - if ( -f "/sw/include/gdbm.h" ) { - $conf->data->add( ' ', linkflags => '-L/sw/lib' ); - $conf->data->add( ' ', dflags => '-L/sw/lib' ); - $conf->data->add( ' ', cflags => '-I/sw/include' ); + my $fink_lib_dir = $conf->data->get('fink_lib_dir'); + my $fink_include_dir = $conf->data->get('fink_include_dir'); + if ( -f "$fink_include_dir/gdbm.h" ) { + $conf->data->add( ' ', linkflags => "-L$fink_lib_dir" ); + $conf->data->add( ' ', dflags => "-L$fink_lib_dir" ); + $conf->data->add( ' ', cflags => "-I$fink_include_dir" ); } } Modified: trunk/config/auto/gmp.pm ============================================================================== --- trunk/config/auto/gmp.pm (original) +++ trunk/config/auto/gmp.pm Thu Jan 3 16:28:56 2008 @@ -66,13 +66,13 @@ # On OS X check the presence of the gmp header in the standard # Fink location. - # RT#43134: Need a more generalized way for finding - # where Fink lives. if ( $osname =~ /darwin/ ) { - if ( -f "/sw/include/gmp.h" ) { - $conf->data->add( ' ', linkflags => '-L/sw/lib' ); - $conf->data->add( ' ', ldflags => '-L/sw/lib' ); - $conf->data->add( ' ', ccflags => '-I/sw/include' ); + my $fink_lib_dir = $conf->data->get('fink_lib_dir'); + my $fink_include_dir = $conf->data->get('fink_include_dir'); + if ( -f "$fink_include_dir/gmp.h" ) { + $conf->data->add( ' ', linkflags => "-L$fink_lib_dir" ); + $conf->data->add( ' ', ldflags => "-L$fink_lib_dir" ); + $conf->data->add( ' ', ccflags => "-I$fink_include_dir" ); } } Modified: trunk/config/auto/readline.pm ============================================================================== --- trunk/config/auto/readline.pm (original) +++ trunk/config/auto/readline.pm Thu Jan 3 16:28:56 2008 @@ -55,13 +55,13 @@ # On OS X check the presence of the readline header in the standard # Fink/macports location. - # RT#43134: Need a more generalized way for finding - # where Fink lives. if ( $osname =~ /darwin/ ) { - if ( -f "/sw/include/readline/readline.h" ) { - $conf->data->add( ' ', linkflags => '-L/sw/lib' ); - $conf->data->add( ' ', ldflags => '-L/sw/lib' ); - $conf->data->add( ' ', ccflags => '-I/sw/include' ); + my $fink_lib_dir = $conf->data->get('fink_lib_dir'); + my $fink_include_dir = $conf->data->get('fink_include_dir'); + if ( -f "$fink_include_dir/readline/readline.h" ) { + $conf->data->add( ' ', linkflags => "-L$fink_lib_dir" ); + $conf->data->add( ' ', ldflags => "-L$fink_lib_dir" ); + $conf->data->add( ' ', ccflags => "-I$fink_include_dir" ); } if ( -f "/opt/local/include/readline/readline.h" ) { $conf->data->add( ' ', linkflags => '-L/opt/local/lib' ); Modified: trunk/lib/Parrot/Configure/Step/List.pm ============================================================================== --- trunk/lib/Parrot/Configure/Step/List.pm (original) +++ trunk/lib/Parrot/Configure/Step/List.pm Thu Jan 3 16:28:56 2008 @@ -20,6 +20,7 @@ inter::yacc auto::gcc auto::backtrace + auto::fink auto::msvc auto::attributes auto::warnings Added: trunk/t/configure/113-auto_fink-01.t ============================================================================== --- (empty file) +++ trunk/t/configure/113-auto_fink-01.t Thu Jan 3 16:28:56 2008 @@ -0,0 +1,81 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 113-auto_fink-01.t + +use strict; +use warnings; +use Test::More; +plan( skip_all => 'Fink is Darwin only' ) unless $^O =~ /darwin/; +plan( tests => 11 ); +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::fink'); + +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Test qw( test_step_thru_runstep); + +my $args = process_options( { + argv => [], + mode => q{configure}, +} ); + +my $conf = Parrot::Configure->new(); + +test_step_thru_runstep($conf, q{init::defaults}, $args); + +my ($task, $step_name, $step, $ret); +my $pkg = q{auto::fink}; + +$conf->add_steps($pkg); +$conf->options->set(%{$args}); +$task = $conf->steps->[-1]; +$step_name = $task->step; + +$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"); + +# Success in the following test means: +# (a) OS is Darwin. +# (b) Either Fink is not installed or it is installed correctly, i.e., we can +# locate the Fink subdirectories we need for later Parrot configuration steps. +ok($step->runstep($conf), "runstep() returned true value"); + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +113-auto_fink-01.t - test config::auto::fink + +=head1 SYNOPSIS + + % prove t/configure/113-auto_fink-01.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file run on Darwin only and test config::auto::fink. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::fink, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Added: trunk/t/configure/113-auto_fink-02.t ============================================================================== --- (empty file) +++ trunk/t/configure/113-auto_fink-02.t Thu Jan 3 16:28:56 2008 @@ -0,0 +1,79 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 113-auto_fink-02.t + +use strict; +use warnings; +use Test::More tests => 12; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::fink'); + +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Test qw( test_step_thru_runstep); + +my $args = process_options( { + argv => [], + mode => q{configure}, +} ); + +my $conf = Parrot::Configure->new(); + +test_step_thru_runstep($conf, q{init::defaults}, $args); + +my ($task, $step_name, $step, $ret); +my $pkg = q{auto::fink}; + +$conf->add_steps($pkg); +$conf->options->set(%{$args}); +$task = $conf->steps->[-1]; +$step_name = $task->step; + +$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"); + +# mock not Darwin +$conf->data->set_p5( 'OSNAME' => 'foobar' ); +ok($step->runstep($conf), "runstep() returned true value"); +is($step->result(), q{skipped}, "Got expected result for non-Darwin OS"); + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +113-auto_fink-02.t - test config::auto::fink + +=head1 SYNOPSIS + + % prove t/configure/113-auto_fink-02.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test config::auto::fink in the case where the OS is not +Darwin. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::fink, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Added: trunk/t/configure/113-auto_fink-03.t ============================================================================== --- (empty file) +++ trunk/t/configure/113-auto_fink-03.t Thu Jan 3 16:28:56 2008 @@ -0,0 +1,82 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 113-auto_fink-03.t + +use strict; +use warnings; +use Test::More; +plan( skip_all => 'Fink is Darwin only' ) unless $^O =~ /darwin/; +plan( tests => 12 ); +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::fink'); +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Test qw( test_step_thru_runstep); + +my $args = process_options( { + argv => [], + mode => q{configure}, +} ); + +my $conf = Parrot::Configure->new(); + +test_step_thru_runstep($conf, q{init::defaults}, $args); + +my ($task, $step_name, $step, $ret); +my $pkg = q{auto::fink}; + +$conf->add_steps($pkg); +$conf->options->set(%{$args}); +$task = $conf->steps->[-1]; +$step_name = $task->step; + +$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"); + +# mock no Fink +$step->{fink_conf} = q{my_ridiculous_foobar}; +my $msg = q{Fink not installed}; +ok($step->runstep($conf), "runstep() returned true value"); +is($step->result(), $msg, + "Got expected result for $msg"); + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +113-auto_fink-03.t - test config::auto::fink + +=head1 SYNOPSIS + + % prove t/configure/113-auto_fink-03.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test config::auto::fink in the case where the OS is +Darwin but Fink is not installed. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::fink, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Added: trunk/t/configure/113-auto_fink-04.t ============================================================================== --- (empty file) +++ trunk/t/configure/113-auto_fink-04.t Thu Jan 3 16:28:56 2008 @@ -0,0 +1,91 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 113-auto_fink-04.t + +use strict; +use warnings; +use Test::More; +plan( skip_all => 'Fink is Darwin only' ) unless $^O =~ /darwin/; +plan( tests => 12 ); +# plan( 'no_plan' ); +use Carp; +use File::Temp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::fink'); +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Test qw( test_step_thru_runstep); + +my $args = process_options( { + argv => [], + mode => q{configure}, +} ); + +my $conf = Parrot::Configure->new(); + +test_step_thru_runstep($conf, q{init::defaults}, $args); + +my ($task, $step_name, $step, $ret); +my $pkg = q{auto::fink}; + +$conf->add_steps($pkg); +$conf->options->set(%{$args}); +$task = $conf->steps->[-1]; +$step_name = $task->step; + +$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"); + +{ + # mock Fink config file with no Basepath + my $tfile = File::Temp->new(); + open my $fh, ">", $tfile + or croak "Unable to open temporary file for writing"; + print $fh "Message: Hello world\n"; + close $fh or croak "Unable to close temporary file after writing"; + $step->{fink_conf} = $tfile; + ok(! defined $step->runstep($conf), + "runstep() returned undef due to defective Fink config file"); + is($step->result(), q{failed}, + "Got expected result for defective Fink Config file"); +} + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +113-auto_fink-04.t - test config::auto::fink + +=head1 SYNOPSIS + + % prove t/configure/113-auto_fink-04.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test config::auto::fink in the case where the Fink +configuration file is defective. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::fink, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Added: trunk/t/configure/113-auto_fink-05.t ============================================================================== --- (empty file) +++ trunk/t/configure/113-auto_fink-05.t Thu Jan 3 16:28:56 2008 @@ -0,0 +1,91 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 113-auto_fink-05.t + +use strict; +use warnings; +use Test::More; +plan( skip_all => 'Fink is Darwin only' ) unless $^O =~ /darwin/; +plan( tests => 12 ); +# plan( 'no_plan' ); +use Carp; +use File::Temp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::fink'); +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Test qw( test_step_thru_runstep); + +my $args = process_options( { + argv => [], + mode => q{configure}, +} ); + +my $conf = Parrot::Configure->new(); + +test_step_thru_runstep($conf, q{init::defaults}, $args); + +my ($task, $step_name, $step, $ret); +my $pkg = q{auto::fink}; + +$conf->add_steps($pkg); +$conf->options->set(%{$args}); +$task = $conf->steps->[-1]; +$step_name = $task->step; + +$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"); + +{ + # mock Fink config file with non-existent Basepath + my $tfile = File::Temp->new(); + open my $fh, ">", $tfile + or croak "Unable to open temporary file for writing"; + print $fh "Basepath: /my/phony/directory\n"; + close $fh or croak "Unable to close temporary file after writing"; + $step->{fink_conf} = $tfile; + ok(! defined $step->runstep($conf), + "runstep() returned undef due to unlocateable Fink directories"); + is($step->result(), q{failed}, + "Got expected result for unlocateable Fink directories"); +} + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +113-auto_fink-05.t - test config::auto::fink + +=head1 SYNOPSIS + + % prove t/configure/113-auto_fink-05.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test config::auto::fink in the case where the one or +more of the Fink directories cannot be located. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::fink, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Added: trunk/t/configure/113-auto_fink-06.t ============================================================================== --- (empty file) +++ trunk/t/configure/113-auto_fink-06.t Thu Jan 3 16:28:56 2008 @@ -0,0 +1,90 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 113-auto_fink-06.t + +use strict; +use warnings; +use Test::More tests => 13; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::fink'); +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Test qw( test_step_thru_runstep); +use IO::CaptureOutput qw| capture |; + +my $args = process_options( { + argv => [ q{--verbose} ], + mode => q{configure}, +} ); + +my $conf = Parrot::Configure->new(); + +test_step_thru_runstep($conf, q{init::defaults}, $args); + +my ($task, $step_name, $step, $ret); +my $pkg = q{auto::fink}; + +$conf->add_steps($pkg); +$conf->options->set(%{$args}); +$task = $conf->steps->[-1]; +$step_name = $task->step; + +$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"); + +{ + # mock not Darwin + my $phony_OS = q{foobar}; + $conf->data->set_p5( 'OSNAME' => $phony_OS ); + my ($rv, $stdout); + capture( + sub { $rv = $step->runstep($conf); }, + \$stdout, + ); + ok($rv, "runstep() returned true value"); + is($step->result(), q{skipped}, "Got expected result for non-Darwin OS"); + like($stdout, + qr/Operating system is $phony_OS; Fink is Darwin only/, + "Got expected verbose output when OS is not Darwin"); +} + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +113-auto_fink-06.t - test config::auto::fink + +=head1 SYNOPSIS + + % prove t/configure/113-auto_fink-06.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test config::auto::fink in the case where the OS is not +Darwin and C<--verbose> output has been requested. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::fink, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Added: trunk/t/configure/113-auto_fink-07.t ============================================================================== --- (empty file) +++ trunk/t/configure/113-auto_fink-07.t Thu Jan 3 16:28:56 2008 @@ -0,0 +1,93 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 113-auto_fink-07.t + +use strict; +use warnings; +use Test::More; +plan( skip_all => 'Fink is Darwin only' ) unless $^O =~ /darwin/; +plan( tests => 13 ); +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::fink'); +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Test qw( test_step_thru_runstep); +use IO::CaptureOutput qw| capture |; + +my $args = process_options( { + argv => [ q{--verbose} ], + mode => q{configure}, +} ); + +my $conf = Parrot::Configure->new(); + +test_step_thru_runstep($conf, q{init::defaults}, $args); + +my ($task, $step_name, $step, $ret); +my $pkg = q{auto::fink}; + +$conf->add_steps($pkg); +$conf->options->set(%{$args}); +$task = $conf->steps->[-1]; +$step_name = $task->step; + +$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"); + +{ + # mock no Fink + $step->{fink_conf} = q{my_ridiculous_foobar}; + my $msg = q{Fink not installed}; + my ($rv, $stdout); + capture( + sub { $rv = $step->runstep($conf); }, + \$stdout, + ); + ok($rv, "runstep() returned true value"); + is($step->result(), $msg, + "Got expected result for $msg"); + like($stdout, + qr/Fink configuration file not located/, + "Got expected verbose output when OS is not Darwin"); +} + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +113-auto_fink-07.t - test config::auto::fink + +=head1 SYNOPSIS + + % prove t/configure/113-auto_fink-07.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test config::auto::fink in the case where the OS is +Darwin but Fink is not installed and C<--verbose> output has been requested. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::fink, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Added: trunk/t/configure/113-auto_fink-08.t ============================================================================== --- (empty file) +++ trunk/t/configure/113-auto_fink-08.t Thu Jan 3 16:28:56 2008 @@ -0,0 +1,101 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 113-auto_fink-08.t + +use strict; +use warnings; +use Test::More; +plan( skip_all => 'Fink is Darwin only' ) unless $^O =~ /darwin/; +plan( tests => 13 ); +# plan( 'no_plan' ); +use Carp; +use File::Temp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::fink'); +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Test qw( test_step_thru_runstep); +use IO::CaptureOutput qw| capture |; + +my $args = process_options( { + argv => [ q{--verbose} ], + mode => q{configure}, +} ); + +my $conf = Parrot::Configure->new(); + +test_step_thru_runstep($conf, q{init::defaults}, $args); + +my ($task, $step_name, $step, $ret); +my $pkg = q{auto::fink}; + +$conf->add_steps($pkg); +$conf->options->set(%{$args}); +$task = $conf->steps->[-1]; +$step_name = $task->step; + +$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"); + +{ + # mock Fink config file with no Basepath + my $tfile = File::Temp->new(); + open my $fh, ">", $tfile + or croak "Unable to open temporary file for writing"; + print $fh "Message: Hello world\n"; + close $fh or croak "Unable to close temporary file after writing"; + $step->{fink_conf} = $tfile; + + my ($rv, $stdout); + capture( + sub { $rv = $step->runstep($conf); }, + \$stdout, + ); + ok(! defined $rv, + "runstep() returned undef due to defective Fink config file"); + is($step->result(), q{failed}, + "Got expected result for defective Fink Config file"); + like($stdout, + qr/Fink configuration file defective: no 'Basepath'/, + "Got expected verbose output when Fink config file lacked 'Basepath'"); +} + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +113-auto_fink-08.t - test config::auto::fink + +=head1 SYNOPSIS + + % prove t/configure/113-auto_fink-08.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test config::auto::fink in the case where the Fink +configuration file is defective. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::fink, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Added: trunk/t/configure/113-auto_fink-09.t ============================================================================== --- (empty file) +++ trunk/t/configure/113-auto_fink-09.t Thu Jan 3 16:28:56 2008 @@ -0,0 +1,101 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 113-auto_fink-09.t + +use strict; +use warnings; +use Test::More; +plan( skip_all => 'Fink is Darwin only' ) unless $^O =~ /darwin/; +plan( tests => 13 ); +# plan( 'no_plan' ); +use Carp; +use File::Temp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::fink'); +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Test qw( test_step_thru_runstep); +use IO::CaptureOutput qw| capture |; + +my $args = process_options( { + argv => [ q{--verbose} ], + mode => q{configure}, +} ); + +my $conf = Parrot::Configure->new(); + +test_step_thru_runstep($conf, q{init::defaults}, $args); + +my ($task, $step_name, $step, $ret); +my $pkg = q{auto::fink}; + +$conf->add_steps($pkg); +$conf->options->set(%{$args}); +$task = $conf->steps->[-1]; +$step_name = $task->step; + +$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"); + +{ + # mock Fink config file with non-existent Basepath + my $tfile = File::Temp->new(); + open my $fh, ">", $tfile + or croak "Unable to open temporary file for writing"; + print $fh "Basepath: /my/phony/directory\n"; + close $fh or croak "Unable to close temporary file after writing"; + $step->{fink_conf} = $tfile; + + my ($rv, $stdout); + capture( + sub { $rv = $step->runstep($conf); }, + \$stdout, + ); + ok(! defined $rv, + "runstep() returned undef due to unlocateable Fink directories"); + is($step->result(), q{failed}, + "Got expected result for unlocateable Fink directories"); + like($stdout, + qr/Could not locate Fink directories/, + "Got expected verbose output for unlocateable Fink directories"); +} + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +113-auto_fink-09.t - test config::auto::fink + +=head1 SYNOPSIS + + % prove t/configure/113-auto_fink-09.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test config::auto::fink in the case where the one or +more of the Fink directories cannot be located. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::fink, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: