The patch attached refactors configuration step auto::ctags to maximize
testability. It also provides 3 test files to replace ptc's original
test file. ptc's original functionality is, however, maintained intact.
Assuming no objection, I'll apply this in 2-3 days.
Thank you very much.
kid51
Index: MANIFEST
===================================================================
--- MANIFEST (revision 22709)
+++ MANIFEST (working copy)
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Sun Nov 4 15:38:46 2007 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Mon Nov 5 01:34:29 2007 UT
#
# See tools/dev/install_files.pl for documentation on the
# format of this file.
@@ -3094,7 +3094,10 @@
t/configure/147-auto_perldoc.t []
t/configure/148-auto_python.t []
t/configure/149-auto_m4.t []
-t/configure/150-auto_ctags.t []
+t/configure/150-auto_ctags-01.t []
+t/configure/150-auto_ctags-02.t []
+t/configure/150-auto_ctags-03.t []
+t/configure/150-auto_ctags-04.t []
t/configure/151-auto_cpu-01.t []
t/configure/152-auto_revision.t []
t/configure/153-gen_icu.t []
Index: t/configure/150-auto_ctags-04.t
===================================================================
--- t/configure/150-auto_ctags-04.t (revision 0)
+++ t/configure/150-auto_ctags-04.t (revision 0)
@@ -0,0 +1,100 @@
+#!perl
+# Copyright (C) 2001-2007, The Perl Foundation.
+# $Id$
+# 150-auto_ctags-04.t
+
+use strict;
+use warnings;
+use Test::More tests => 17;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+use_ok('config::auto::ctags');
+use Parrot::Configure;
+use Parrot::Configure::Options qw( process_options );
+use Parrot::Configure::Test qw( test_step_thru_runstep);
+use Parrot::IO::Capture::Mini;
+
+my $args = process_options(
+ {
+ argv => [ ],
+ mode => q{configure},
+ }
+);
+
+my $conf = Parrot::Configure->new;
+
+test_step_thru_runstep( $conf, q{init::defaults}, $args );
+
+my $pkg = q{auto::ctags};
+
+$conf->add_steps($pkg);
+$conf->options->set( %{$args} );
+
+my ( $task, $step_name, @step_params, $step);
+$task = $conf->steps->[1];
+$step_name = $task->step;
[EMAIL PROTECTED] = @{ $task->params };
+
+$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" );
+
+ok(auto::ctags::_probe_for_ctags_output('Exuberant Ctags', 0),
+ "Probe returned true when output matched");
+
+ok(! auto::ctags::_probe_for_ctags_output('alpha', 0),
+ "Probe returned false when output matched");
+
+{
+ my $tie_out = tie *STDOUT, "Parrot::IO::Capture::Mini"
+ or croak "Unable to tie";
+ ok(auto::ctags::_probe_for_ctags_output('Exuberant Ctags', 1),
+ "Probe returned true when output matched");
+ my @more_lines = $tie_out->READLINE;
+ ok( @more_lines, "verbose output captured" );
+}
+untie *STDOUT;
+
+{
+ my $tie_out = tie *STDOUT, "Parrot::IO::Capture::Mini"
+ or croak "Unable to tie";
+ ok(! auto::ctags::_probe_for_ctags_output('alpha', 1),
+ "Probe returned false when output matched");
+ my @more_lines = $tie_out->READLINE;
+ ok( @more_lines, "verbose output captured" );
+}
+untie *STDOUT;
+
+pass("Keep Devel::Cover happy");
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+t/configure/150-auto_ctags-04.t - tests Parrot::Configure::Step::auto::ctags
+
+=head1 SYNOPSIS
+
+ prove t/configure/150-auto_ctags-04.t
+
+=head1 DESCRIPTION
+
+Regression tests for the L<Parrot::Configure::Step::auto::ctags> module.
+This file holds tests for Parrot::Configure::Step::auto::ctags::runstep()
+(a non-exported subroutine).
+
+=head1 AUTHOR
+
+Paul Cochrane <paultcochrane at gmail dot com>
+
+=cut
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
Property changes on: t/configure/150-auto_ctags-04.t
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Index: t/configure/150-auto_ctags.t
===================================================================
--- t/configure/150-auto_ctags.t (revision 22709)
+++ t/configure/150-auto_ctags.t (working copy)
@@ -1,72 +0,0 @@
-#!perl
-# Copyright (C) 2001-2007, The Perl Foundation.
-# $Id$
-
-use strict;
-use warnings;
-
-use Test::More;
-use IO::Handle;
-use lib qw( lib );
-use Parrot::IO::Capture::Mini;
-
-if ( $^O eq 'MSWin32' ) {
- plan( skip_all => 'Not yet tested on Win32' );
-}
-else {
- plan( tests => 8 );
-}
-
-use_ok('Parrot::Configure');
-use_ok('Parrot::Configure::Step');
-use_ok('Parrot::Configure::Step::Base');
-use_ok('auto::ctags');
-
-my $conf = Parrot::Configure->new;
-my $pkg = q{auto::ctags};
-
-$conf->add_steps($pkg);
-
-my $task = $conf->steps->[0];
-my $step_name = $task->step;
-
-my $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" );
-
-{
- my $verbose = 0;
- my $rv = auto::ctags::runstep($step, $conf);
- is( $rv, 1, "Got expected exit code of 1" );
-}
-
-################### DOCUMENTATION ###################
-
-=head1 NAME
-
-t/configure/118-detect_ctags.t - tests Parrot::Configure::Step::auto::ctags
-
-=head1 SYNOPSIS
-
- prove t/configure/118-detect_ctags.t
-
-=head1 DESCRIPTION
-
-Regression tests for the L<Parrot::Configure::Step::auto::ctags> module.
-This file holds tests for Parrot::Configure::Step::auto::ctags::runstep()
-(a non-exported subroutine).
-
-=head1 AUTHOR
-
-Paul Cochrane <paultcochrane at gmail dot com>
-
-=cut
-
-# Local Variables:
-# mode: cperl
-# cperl-indent-level: 4
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4:
Index: t/configure/150-auto_ctags-01.t
===================================================================
--- t/configure/150-auto_ctags-01.t (revision 0)
+++ t/configure/150-auto_ctags-01.t (revision 0)
@@ -0,0 +1,82 @@
+#!perl
+# Copyright (C) 2001-2007, The Perl Foundation.
+# $Id$
+# 150-auto_ctags-01.t
+
+use strict;
+use warnings;
+use Test::More tests => 14;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+use_ok('config::auto::ctags');
+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 $pkg = q{auto::ctags};
+
+$conf->add_steps($pkg);
+$conf->options->set( %{$args} );
+
+my ( $task, $step_name, @step_params, $step);
+$task = $conf->steps->[1];
+$step_name = $task->step;
[EMAIL PROTECTED] = @{ $task->params };
+
+$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" );
+
+my %possible_ctags = map {$_,1}
+ qw( ctags exuberant-ctags ctags-exuberant exctags );
+
+my $ret = $step->runstep($conf);
+ok( $ret, "$step_name runstep() returned true value" );
+ok(defined($step->result()), "Result was defined");
+ok($possible_ctags{$conf->data->get('ctags')},
+ "Acceptable value for 'ctags' attribute was set");
+
+pass("Keep Devel::Cover happy");
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+t/configure/150-auto_ctags-01.t - tests Parrot::Configure::Step::auto::ctags
+
+=head1 SYNOPSIS
+
+ prove t/configure/150-auto_ctags-01.t
+
+=head1 DESCRIPTION
+
+Regression tests for the L<Parrot::Configure::Step::auto::ctags> module.
+This file holds tests for Parrot::Configure::Step::auto::ctags::runstep()
+(a non-exported subroutine).
+
+=head1 AUTHOR
+
+Paul Cochrane <paultcochrane at gmail dot com>
+
+=cut
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
Property changes on: t/configure/150-auto_ctags-01.t
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Index: t/configure/150-auto_ctags-02.t
===================================================================
--- t/configure/150-auto_ctags-02.t (revision 0)
+++ t/configure/150-auto_ctags-02.t (revision 0)
@@ -0,0 +1,88 @@
+#!perl
+# Copyright (C) 2001-2007, The Perl Foundation.
+# $Id$
+# 150-auto_ctags-02.t
+
+use strict;
+use warnings;
+use Test::More tests => 15;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+$ENV{TEST_CTAGS} = [ ( 'foobar' ) ];
+use_ok('config::auto::ctags');
+use Parrot::Configure;
+use Parrot::Configure::Options qw( process_options );
+use Parrot::Configure::Test qw( test_step_thru_runstep);
+use Parrot::IO::Capture::Mini;
+
+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 $pkg = q{auto::ctags};
+
+$conf->add_steps($pkg);
+$conf->options->set( %{$args} );
+
+my ( $task, $step_name, @step_params, $step);
+$task = $conf->steps->[1];
+$step_name = $task->step;
[EMAIL PROTECTED] = @{ $task->params };
+
+$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" );
+
+{
+ my $tie_out = tie *STDOUT, "Parrot::IO::Capture::Mini"
+ or croak "Unable to tie";
+ my $ret = $step->runstep($conf);
+ ok( $ret, "$step_name runstep() returned true value" );
+ my @more_lines = $tie_out->READLINE;
+ ok( @more_lines, "verbose output captured" );
+ is($step->result(), q{no}, "Got expected result");
+ is($conf->data->get('ctags'), 'ctags',
+ "Correct value for 'ctags' attribute was set");
+}
+untie *STDOUT;
+
+pass("Keep Devel::Cover happy");
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+t/configure/150-auto_ctags-02.t - tests Parrot::Configure::Step::auto::ctags
+
+=head1 SYNOPSIS
+
+ prove t/configure/150-auto_ctags-02.t
+
+=head1 DESCRIPTION
+
+Regression tests for the L<Parrot::Configure::Step::auto::ctags> module.
+This file holds tests for Parrot::Configure::Step::auto::ctags::runstep()
+(a non-exported subroutine).
+
+=head1 AUTHOR
+
+Paul Cochrane <paultcochrane at gmail dot com>
+
+=cut
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
Property changes on: t/configure/150-auto_ctags-02.t
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Index: t/configure/150-auto_ctags-03.t
===================================================================
--- t/configure/150-auto_ctags-03.t (revision 0)
+++ t/configure/150-auto_ctags-03.t (revision 0)
@@ -0,0 +1,79 @@
+#!perl
+# Copyright (C) 2001-2007, The Perl Foundation.
+# $Id$
+# 150-auto_ctags-03.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::ctags');
+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 $pkg = q{auto::ctags};
+
+$conf->add_steps($pkg);
+$conf->options->set( %{$args} );
+
+my ( $task, $step_name, @step_params, $step);
+$task = $conf->steps->[1];
+$step_name = $task->step;
[EMAIL PROTECTED] = @{ $task->params };
+
+$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" );
+
+my $pseudo_ctags = q{alpha};
+$step->_evaluate_ctags($conf, $pseudo_ctags, 1);
+is($conf->data->get('ctags'), $pseudo_ctags,
+ "'ctags' attribute was set as expected");
+is($step->result(), q{yes}, "Got expected result");
+
+pass("Keep Devel::Cover happy");
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+t/configure/150-auto_ctags-03.t - tests Parrot::Configure::Step::auto::ctags
+
+=head1 SYNOPSIS
+
+ prove t/configure/150-auto_ctags-03.t
+
+=head1 DESCRIPTION
+
+Regression tests for the L<Parrot::Configure::Step::auto::ctags> module.
+This file holds tests for Parrot::Configure::Step::auto::ctags::runstep()
+(a non-exported subroutine).
+
+=head1 AUTHOR
+
+Paul Cochrane <paultcochrane at gmail dot com>
+
+=cut
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
Property changes on: t/configure/150-auto_ctags-03.t
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Index: config/auto/ctags.pm
===================================================================
--- config/auto/ctags.pm (revision 22709)
+++ config/auto/ctags.pm (working copy)
@@ -33,34 +33,53 @@
return \%data;
}
-our $verbose;
+my @ctags_variations =
+ defined( $ENV{TEST_CTAGS} )
+ ? @{ $ENV{TEST_CTAGS} }
+ : qw( ctags exuberant-ctags ctags-exuberant exctags );
sub runstep {
my ( $self, $conf ) = @_;
- $verbose = $conf->options->get( 'verbose' );
+ my $verbose = $conf->options->get( 'verbose' );
print "\n" if $verbose;
- my @ctags_variations = qw( ctags exuberant-ctags ctags-exuberant exctags );
- for my $ctags ( @ctags_variations ) {
- my $output = capture_output( $ctags, '--version' ) || '';
+ my ($ctags, $has_ctags) =
+ _probe_for_ctags([ @ctags_variations ], $verbose);
+ $self->_evaluate_ctags($conf, $ctags, $has_ctags);
+ return 1;
+}
+
+sub _probe_for_ctags {
+ my $variations_ref = shift;
+ my $verbose = shift;
+ my ($ctags, $has_ctags);
+ while (defined (my $t = shift(@$variations_ref))) {
+ my $output = capture_output( $t, '--version' ) || '';
print $output, "\n" if $verbose;
- my $has_ctags = ( $output =~ m/Exuberant Ctags/ ) ? 1 : 0;
- print $has_ctags, "\n" if $verbose;
-
- if ( $has_ctags ) {
- $conf->data->set( ctags => $ctags );
- $self->set_result( 'yes' );
- return 1;
- }
+ $has_ctags = _probe_for_ctags_output($output, $verbose);
+ $ctags = $t if $has_ctags;
+ next unless $has_ctags;
}
+ return ($ctags, $has_ctags);
+}
- # if we get to here, we didn't find a decent ctags; so just set it to
- # ctags so that the Makefile is happy
- $conf->data->set( ctags => 'ctags' );
- $self->set_result( 'no' );
+sub _probe_for_ctags_output {
+ my ($output, $verbose) = @_;
+ my $has_ctags = ( $output =~ m/Exuberant Ctags/ ) ? 1 : 0;
+ print $has_ctags, "\n" if $verbose;
+ return $has_ctags;
+}
- return 1;
+sub _evaluate_ctags {
+ my ($self, $conf, $ctags, $has_ctags) = @_;
+ if ($has_ctags) {
+ $conf->data->set( ctags => $ctags );
+ $self->set_result( 'yes' );
+ } else {
+ $conf->data->set( ctags => 'ctags' );
+ $self->set_result( 'no' );
+ }
}
1;