[svn:DBD-Pg] r13052 - in DBD-Pg/trunk: . t

[email protected]
Newsgroups gmane.comp.db.postgresql.dbdpg.cvs
Message-ID <[email protected]>
Author: turnstep
Date: Mon Jul 13 12:25:54 2009
New Revision: 13052

Added:
   DBD-Pg/trunk/t/00_release.t
Modified:
   DBD-Pg/trunk/MANIFEST.SKIP

Log:
Add new test to track version numbers.


Modified: DBD-Pg/trunk/MANIFEST.SKIP
==============================================================================
--- DBD-Pg/trunk/MANIFEST.SKIP	(original)
+++ DBD-Pg/trunk/MANIFEST.SKIP	Mon Jul 13 12:25:54 2009
@@ -26,4 +26,4 @@
 cover_db/
 dbdpg_test_database/*
 versiontest/*
-
+t/00_release.t

Added: DBD-Pg/trunk/t/00_release.t
==============================================================================
--- (empty file)
+++ DBD-Pg/trunk/t/00_release.t	Mon Jul 13 12:25:54 2009
@@ -0,0 +1,93 @@
+#!perl
+
+## Make sure the version number is consistent in all places
+
+use 5.006;
+use strict;
+use warnings;
+use Data::Dumper;
+use Test::More;
+use lib 't','.';
+
+if (!$ENV{TEST_AUTHOR}) {
+	plan skip_all => 'Set the environment variable TEST_AUTHOR to enable this test';
+}
+plan tests => 1;
+
+my %v;
+my $vre = qr{(\d+\.\d+\.\d+\_?\d*)};
+
+## Grab version from various files
+my $file = 'META.yml';
+open my $fh, '<', $file or die qq{Could not open "$file": $!\n};
+while (<$fh>) {
+	push @{$v{$file}} => [$1,$.] if /version\s*:\s*$vre/;
+}
+close $fh or warn qq{Could not close "$file": $!\n};
+
+$file = 'Makefile.PL';
+open $fh, '<', $file or die qq{Could not open "$file": $!\n};
+while (<$fh>) {
+	push @{$v{$file}} => [$1,$.] if /VERSION = '$vre'/;
+}
+close $fh or warn qq{Could not close "$file": $!\n};
+
+$file = 'Pg.pm';
+open $fh, '<', $file or die qq{Could not open "$file": $!\n};
+while (<$fh>) {
+	push @{$v{$file}} => [$1,$.] if (/VERSION = qv\('$vre'/ or /documents version $vre/);
+}
+close $fh or warn qq{Could not close "$file": $!\n};
+
+$file = 'lib/Bundle/DBD/Pg.pm';
+open $fh, '<', $file or die qq{Could not open "$file": $!\n};
+while (<$fh>) {
+	push @{$v{$file}} => [$1,$.] if /VERSION = '$vre'/;
+}
+close $fh or warn qq{Could not close "$file": $!\n};
+
+$file = 'Changes';
+open $fh, '<', $file or die qq{Could not open "$file": $!\n};
+while (<$fh>) {
+	if (/^$vre/) {
+		push @{$v{$file}} => [$1,$.];
+		last;
+	}
+}
+close $fh or warn qq{Could not close "$file": $!\n};
+
+$file = 'README';
+open $fh, '<', $file or die qq{Could not open "$file": $!\n};
+while (<$fh>) {
+	push @{$v{$file}} => [$1,$.] if (/is version $vre/ or /TEST VERSION \($vre/);
+}
+close $fh or warn qq{Could not close "$file": $!\n};
+
+my $good = 1;
+my $lastver;
+for my $filename (keys %v) {
+	for my $glob (@{$v{$filename}}) {
+		my ($ver,$line) = @$glob;
+		if (! defined $lastver) {
+			$lastver = $ver;
+		}
+		elsif ($ver ne $lastver) {
+			$good = 0;
+		}
+	}
+}
+
+if ($good) {
+	pass "All version numbers are the same ($lastver)";
+}
+else {
+	fail 'All version numbers were not the same!';
+	for my $filename (sort keys %v) {
+		for my $glob (@{$v{$filename}}) {
+			my ($ver,$line) = @$glob;
+			diag "File: $filename. Line: $line. Version: $ver\n";
+		}
+	}
+}
+
+exit;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.