Author: jkeenan
Date: Thu May 3 18:37:47 2007
New Revision: 18416
Added:
branches/reconfigure/t/configure/19-version.t (contents, props changed)
branches/reconfigure/t/configure/20-version.t (contents, props changed)
branches/reconfigure/t/configure/21-version.t (contents, props changed)
branches/reconfigure/t/configure/22-version.t (contents, props changed)
branches/reconfigure/t/configure/23-version.t (contents, props changed)
branches/reconfigure/t/configure/24-version.t (contents, props changed)
branches/reconfigure/t/configure/testlib/Make_VERSION_File.pm (contents,
props changed)
Modified:
branches/reconfigure/MANIFEST
branches/reconfigure/MANIFEST.SKIP
branches/reconfigure/lib/Parrot/BuildUtil.pm
Log:
1. Refactored Parrot::BuildUtils::parrot_version() to eliminate unreachable
code.
2. Added additional POD to lib/Parrot/BuildUtils.pm.
3. Added 6 test files in t/configure (plus one module exporting a subroutine
used during tests). Tests now provide 100% coverage of code.
4. New files added to MANIFEST.
Modified: branches/reconfigure/MANIFEST
==============================================================================
--- branches/reconfigure/MANIFEST (original)
+++ branches/reconfigure/MANIFEST Thu May 3 18:37:47 2007
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Thu May 3 23:11:48 2007 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Fri May 4 01:05:15 2007 UT
#
# See tools/dev/install_files.pl for documentation on the
# format of this file.
@@ -2807,10 +2807,17 @@
t/configure/16-no_return_but_result.t []
t/configure/17-revision_no_DEVELOPING.t []
t/configure/18-revision.t []
+t/configure/19-version.t []
+t/configure/20-version.t []
+t/configure/21-version.t []
+t/configure/22-version.t []
+t/configure/23-version.t []
+t/configure/24-version.t []
t/configure/base.t []
t/configure/config_steps.t []
t/configure/data.t []
t/configure/step.t []
+t/configure/testlib/Make_VERSION_File.pm []
t/configure/testlib/init/alpha.pm []
t/configure/testlib/init/beta.pm []
t/configure/testlib/init/delta.pm []
Modified: branches/reconfigure/MANIFEST.SKIP
==============================================================================
--- branches/reconfigure/MANIFEST.SKIP (original)
+++ branches/reconfigure/MANIFEST.SKIP Thu May 3 18:37:47 2007
@@ -1,6 +1,6 @@
# ex: set ro:
# $Id$
-# generated by tools/dev/mk_manifest_and_skip.pl Thu May 3 23:11:48 2007 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Fri May 4 01:05:15 2007 UT
#
# This file should contain a transcript of the svn:ignore properties
# of the directories in the Parrot subversion repository. (Needed for
Modified: branches/reconfigure/lib/Parrot/BuildUtil.pm
==============================================================================
--- branches/reconfigure/lib/Parrot/BuildUtil.pm (original)
+++ branches/reconfigure/lib/Parrot/BuildUtil.pm Thu May 3 18:37:47 2007
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2006, The Perl Foundation.
+# Copyright (C) 2001-2007, The Perl Foundation.
# $Id$
=head1 NAME
@@ -7,28 +7,36 @@
=head1 DESCRIPTION
-For now only a sub for getting the current version.
-
-=head2 Functions
-
-=over 4
+For now, this package contains only one subroutine: C<parrot_version()>.
+This subroutine is not exported and so must be requested with a fully
+qualified path.
=cut
package Parrot::BuildUtil;
-
use strict;
use warnings;
+=head2 SUBROUTINES
+
+=over 4
+
=item C<parrot_version()>
-Determine the current version number for Parrot from the VERSION file
-and return it.
+Determines the current version number for Parrot from the VERSION file
+and returns it in a context-appropriate manner.
+
+ $parrot_version = Parrot::BuildUtil::parrot_version();
+ # $parrot_version is '0.4.11'
+
+ @parrot_version = Parrot::BuildUtil::parrot_version();
+ # @parrot_version is (0, 4, 11)
+
+=back
=cut
# cache for repeated calls
-# XXX this could be in BEGIN block
my ( $parrot_version, @parrot_version );
sub parrot_version {
@@ -38,10 +46,9 @@
# Obtain the official version number from the VERSION file.
open my $VERSION, '<', 'VERSION' or die "Could not open VERSION file!";
- $parrot_version = <$VERSION>;
+ chomp( $parrot_version = <$VERSION> );
close $VERSION;
- chomp $parrot_version;
$parrot_version =~ s/\s+//g;
@parrot_version = split( /\./, $parrot_version );
@@ -53,30 +60,23 @@
die "Too many components to VERSION file contents: '$parrot_version'
(should be 3 or 4)!";
}
- foreach (@parrot_version) {
- die "Illegal version component: '$_' in VERSION file!" unless
m/^[1-9]*\w*$/;
+ foreach my $component (@parrot_version) {
+ die "Illegal version component: '$component' in VERSION file!"
+ unless $component =~ m/^\d+$/;
}
- if ( @parrot_version == 4 ) {
-
- # $parrot_version[2] = $parrot_version[2] . "_" .
$parrot_version[3];
- $#parrot_version = 3;
- }
$parrot_version = join( '.', @parrot_version );
-
return wantarray ? @parrot_version : $parrot_version;
}
-=back
+1;
=head1 AUTHOR
-Gregor N. Purdy
+Gregor N. Purdy. Revised by James E Keenan.
=cut
-1;
-
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
Added: branches/reconfigure/t/configure/19-version.t
==============================================================================
--- (empty file)
+++ branches/reconfigure/t/configure/19-version.t Thu May 3 18:37:47 2007
@@ -0,0 +1,71 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 19-version.t
+
+use strict;
+use warnings;
+
+use Test::More tests => 10;
+use Carp;
+use_ok( 'Cwd' );
+use_ok( 'File::Copy' );
+use_ok( 'File::Temp', qw| tempdir | );
+use lib qw( . lib ../lib ../../lib );
+
+my $cwd = cwd();
+my $errstr;
+{
+ my $tdir = tempdir();
+ ok(chdir $tdir, "Changed to temporary directory for testing");
+ ok((mkdir "lib"), "Able to make directory lib");
+ ok((mkdir "lib/Parrot"), "Able to make directory lib/Parrot");
+ ok(copy ("$cwd/lib/Parrot/BuildUtil.pm", "lib/Parrot/"),
+ "Able to copy Parrot::BuildUtil for testing");
+ unshift(@INC, "lib");
+
+ require Parrot::BuildUtil;
+
+ # Case 1: No VERSION file
+ eval { my $pv = Parrot::BuildUtil::parrot_version(); };
+ like($@, qr/Could not open VERSION file!/,
+ "Absence of VERSION file correctly detected");
+
+ ok(chdir $cwd, "Able to change back to directory after testing");
+}
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+19-version.t - test C<Parrot::BuildUtil::parrot_version()>
+
+=head1 SYNOPSIS
+
+ % prove t/configure/19-version.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file test Parrot::BuildUtil (F<lib/Parrot/BuildUtil.pm>).
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+Parrot::BuildUtil, F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
+
Added: branches/reconfigure/t/configure/20-version.t
==============================================================================
--- (empty file)
+++ branches/reconfigure/t/configure/20-version.t Thu May 3 18:37:47 2007
@@ -0,0 +1,74 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 20-version.t
+
+use strict;
+use warnings;
+
+use Test::More tests => 11;
+use Carp;
+use_ok( 'Cwd' );
+use_ok( 'File::Copy' );
+use_ok( 'File::Temp', qw| tempdir | );
+use lib qw( . lib ../lib ../../lib t/configure/testlib );
+use_ok( 'Make_VERSION_File', qw| make_VERSION_file |);
+
+my $cwd = cwd();
+my $errstr;
+{
+ my $tdir = tempdir();
+ ok(chdir $tdir, "Changed to temporary directory for testing");
+ ok((mkdir "lib"), "Able to make directory lib");
+ ok((mkdir "lib/Parrot"), "Able to make directory lib/Parrot");
+ ok(copy ("$cwd/lib/Parrot/BuildUtil.pm", "lib/Parrot/"),
+ "Able to copy Parrot::BuildUtil for testing");
+ unshift(@INC, "lib");
+
+ require Parrot::BuildUtil;
+
+ # Case 2: VERSION file with <3-element version number
+ make_VERSION_file(q{0.4});
+ eval {
+ my $pv = Parrot::BuildUtil::parrot_version();
+ };
+ like($@, qr/Too few components to VERSION file contents/,
+ "Correctly detected too few components in version number");
+
+ ok(chdir $cwd, "Able to change back to directory after testing");
+}
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+20-version.t - test C<Parrot::BuildUtil::parrot_version()>
+
+=head1 SYNOPSIS
+
+ % prove t/configure/20-version.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file test Parrot::BuildUtil (F<lib/Parrot/BuildUtil.pm>).
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+Parrot::BuildUtil, F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
+
Added: branches/reconfigure/t/configure/21-version.t
==============================================================================
--- (empty file)
+++ branches/reconfigure/t/configure/21-version.t Thu May 3 18:37:47 2007
@@ -0,0 +1,74 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 21-version.t
+
+use strict;
+use warnings;
+
+use Test::More tests => 11;
+use Carp;
+use_ok( 'Cwd' );
+use_ok( 'File::Copy' );
+use_ok( 'File::Temp', qw| tempdir | );
+use lib qw( . lib ../lib ../../lib t/configure/testlib );
+use_ok( 'Make_VERSION_File', qw| make_VERSION_file |);
+
+my $cwd = cwd();
+my $errstr;
+{
+ my $tdir = tempdir();
+ ok(chdir $tdir, "Changed to temporary directory for testing");
+ ok((mkdir "lib"), "Able to make directory lib");
+ ok((mkdir "lib/Parrot"), "Able to make directory lib/Parrot");
+ ok(copy ("$cwd/lib/Parrot/BuildUtil.pm", "lib/Parrot/"),
+ "Able to copy Parrot::BuildUtil for testing");
+ unshift(@INC, "lib");
+
+ require Parrot::BuildUtil;
+
+ # Case 3: VERSION file with >4-element version number
+ make_VERSION_file(q{0.4.11.7.5});
+ eval {
+ my $pv = Parrot::BuildUtil::parrot_version();
+ };
+ like($@, qr/Too many components to VERSION file contents/,
+ "Correctly detected too many components in version number");
+
+ ok(chdir $cwd, "Able to change back to directory after testing");
+}
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+21-version.t - test C<Parrot::BuildUtil::parrot_version()>
+
+=head1 SYNOPSIS
+
+ % prove t/configure/21-version.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file test Parrot::BuildUtil (F<lib/Parrot/BuildUtil.pm>).
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+Parrot::BuildUtil, F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
+
Added: branches/reconfigure/t/configure/22-version.t
==============================================================================
--- (empty file)
+++ branches/reconfigure/t/configure/22-version.t Thu May 3 18:37:47 2007
@@ -0,0 +1,75 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 22-version.t
+
+use strict;
+use warnings;
+
+use Test::More tests => 11;
+use Carp;
+use_ok( 'Cwd' );
+use_ok( 'File::Copy' );
+use_ok( 'File::Temp', qw| tempdir | );
+use lib qw( . lib ../lib ../../lib t/configure/testlib );
+use_ok( 'Make_VERSION_File', qw| make_VERSION_file |);
+
+my $cwd = cwd();
+my $errstr;
+{
+ my $tdir = tempdir();
+ ok(chdir $tdir, "Changed to temporary directory for testing");
+ ok((mkdir "lib"), "Able to make directory lib");
+ ok((mkdir "lib/Parrot"), "Able to make directory lib/Parrot");
+ ok(copy ("$cwd/lib/Parrot/BuildUtil.pm", "lib/Parrot/"),
+ "Able to copy Parrot::BuildUtil for testing");
+ unshift(@INC, "lib");
+
+ require Parrot::BuildUtil;
+
+ # Case 4: VERSION file with non-numeric component in version number
+ make_VERSION_file(q{0.tomboy.11});
+ eval {
+ my $pv = Parrot::BuildUtil::parrot_version();
+ };
+ like($@, qr/Illegal version component: 'tomboy'/,
+ "Correctly detected non-numeric component in version number");
+
+ ok(chdir $cwd, "Able to change back to directory after testing");
+}
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+22-version.t - test C<Parrot::BuildUtil::parrot_version()>
+
+=head1 SYNOPSIS
+
+ % prove t/configure/22-version.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file test Parrot::BuildUtil (F<lib/Parrot/BuildUtil.pm>).
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+Parrot::BuildUtil, F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
+
Added: branches/reconfigure/t/configure/23-version.t
==============================================================================
--- (empty file)
+++ branches/reconfigure/t/configure/23-version.t Thu May 3 18:37:47 2007
@@ -0,0 +1,81 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 23-version.t
+
+use strict;
+use warnings;
+
+use Test::More tests => 14;
+use Carp;
+use_ok( 'Cwd' );
+use_ok( 'File::Copy' );
+use_ok( 'File::Temp', qw| tempdir | );
+use lib qw( . lib ../lib ../../lib t/configure/testlib );
+use_ok( 'Make_VERSION_File', qw| make_VERSION_file |);
+
+my $cwd = cwd();
+my $errstr;
+{
+ my $tdir = tempdir();
+ ok(chdir $tdir, "Changed to temporary directory for testing");
+ ok((mkdir "lib"), "Able to make directory lib");
+ ok((mkdir "lib/Parrot"), "Able to make directory lib/Parrot");
+ ok(copy ("$cwd/lib/Parrot/BuildUtil.pm", "lib/Parrot/"),
+ "Able to copy Parrot::BuildUtil for testing");
+ unshift(@INC, "lib");
+
+ require Parrot::BuildUtil;
+
+ # Case 5: Valid version number
+ make_VERSION_file(q{0.4.11});
+ my ($pv, @pv);
+ $pv = Parrot::BuildUtil::parrot_version();
+ @pv = Parrot::BuildUtil::parrot_version();
+ is($pv, q{0.4.11}, "Correct version number returned in scalar context");
+ is_deeply([EMAIL PROTECTED], [ 0, 4, 11 ],
+ "Correct version number returned in scalar context");
+
+ $pv = Parrot::BuildUtil::parrot_version();
+ @pv = Parrot::BuildUtil::parrot_version();
+ is($pv, q{0.4.11}, "Correct version number returned in scalar context");
+ is_deeply([EMAIL PROTECTED], [ 0, 4, 11 ],
+ "Correct version number returned in scalar context");
+ ok(chdir $cwd, "Able to change back to directory after testing");
+}
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+23-version.t - test C<Parrot::BuildUtil::parrot_version()>
+
+=head1 SYNOPSIS
+
+ % prove t/configure/23-version.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file test Parrot::BuildUtil (F<lib/Parrot/BuildUtil.pm>).
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+Parrot::BuildUtil, F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
+
Added: branches/reconfigure/t/configure/24-version.t
==============================================================================
--- (empty file)
+++ branches/reconfigure/t/configure/24-version.t Thu May 3 18:37:47 2007
@@ -0,0 +1,76 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 24-version.t
+
+use strict;
+use warnings;
+
+use Test::More tests => 12;
+use Carp;
+use_ok( 'Cwd' );
+use_ok( 'File::Copy' );
+use_ok( 'File::Temp', qw| tempdir | );
+use lib qw( . lib ../lib ../../lib t/configure/testlib );
+use_ok( 'Make_VERSION_File', qw| make_VERSION_file |);
+
+my $cwd = cwd();
+my $errstr;
+{
+ my $tdir = tempdir();
+ ok(chdir $tdir, "Changed to temporary directory for testing");
+ ok((mkdir "lib"), "Able to make directory lib");
+ ok((mkdir "lib/Parrot"), "Able to make directory lib/Parrot");
+ ok(copy ("$cwd/lib/Parrot/BuildUtil.pm", "lib/Parrot/"),
+ "Able to copy Parrot::BuildUtil for testing");
+ unshift(@INC, "lib");
+
+ require Parrot::BuildUtil;
+
+ # Case 5: Valid version number
+ make_VERSION_file(q{0.4.11});
+ my ($pv, @pv);
+ @pv = Parrot::BuildUtil::parrot_version();
+ $pv = Parrot::BuildUtil::parrot_version();
+ is_deeply([EMAIL PROTECTED], [ 0, 4, 11 ],
+ "Correct version number returned in scalar context");
+ is($pv, q{0.4.11}, "Correct version number returned in scalar context");
+
+ ok(chdir $cwd, "Able to change back to directory after testing");
+}
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+24-version.t - test C<Parrot::BuildUtil::parrot_version()>
+
+=head1 SYNOPSIS
+
+ % prove t/configure/24-version.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file test Parrot::BuildUtil (F<lib/Parrot/BuildUtil.pm>).
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+Parrot::BuildUtil, F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
+
Added: branches/reconfigure/t/configure/testlib/Make_VERSION_File.pm
==============================================================================
--- (empty file)
+++ branches/reconfigure/t/configure/testlib/Make_VERSION_File.pm Thu May
3 18:37:47 2007
@@ -0,0 +1,31 @@
+# Copyright (C) 2001-2003, The Perl Foundation.
+# $Id$
+package Make_VERSION_File;
+use strict;
+use vars qw(@ISA @EXPORT_OK);
[EMAIL PROTECTED] = qw( Exporter );
[EMAIL PROTECTED] = qw( make_VERSION_file );
+
+sub make_VERSION_file {
+ my $v = shift;
+ my $vfile = 'VERSION';
+ open my $FH, ">", $vfile
+ or die "Unable to open $vfile for writing: $!";
+ print $FH $v;
+ close $FH or die "Unable to close $vfile after writing: $!";
+}
+
+1;
+
+=head1 NAME
+
+t/configure/testlib/Make_VERSION_File.pm - Subroutines used in testing
C<Parrot::Build::Util::parrot_version()>
+
+=head1 SYNOPSIS
+
+=head1 AUTHOR
+
+James E Keenan
+
+=cut
+