[check_postgres] [commit] Funky version modification mojo.

check_postgres at bucardo.org check_postgres at bucardo.org
Thu Apr 23 20:18:00 UTC 2009


Committed by Greg Sabino Mullane <greg at endpoint.com>

Funky version modification mojo.

---
 t/CP_Testing.pm |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/t/CP_Testing.pm b/t/CP_Testing.pm
index e3918a9..a0bc04e 100644
--- a/t/CP_Testing.pm
+++ b/t/CP_Testing.pm
@@ -6,6 +6,7 @@ use strict;
 use warnings;
 use Data::Dumper;
 use Time::HiRes qw/sleep/;
+use DBI;
 use Cwd;
 
 our $DEBUG = 0;
@@ -430,6 +431,38 @@ SELECT 'Postgres $version on fakefunction for check_postgres.pl testing'::text;
 
 } ## end of bad fake version
 
+sub fake_self_version {
+
+	## Look out...
+
+	my $self = shift;
+	my $version = shift || '9.9';
+	my $file = 'check_postgres.pl';
+	open my $fh, '+<', $file or die qq{Could not open "$file": $!\n};
+	my $slurp;
+	{ local $/; $slurp = <$fh> }
+	$slurp =~ s/(our \$VERSION = '\d+\.\d+\.\d+';)/$1\n\$VERSION = '$version'; ## TESTING ONLY/;
+	seek $fh, 0, 0;
+	print $fh $slurp;
+	truncate $fh, tell($fh);
+	close $fh or die qq{Could not close "$file": $!\n};
+
+} ## end of fake_self_version
+
+sub restore_self_version {
+
+	my $self = shift;
+	my $file = 'check_postgres.pl';
+	open my $fh, '+<', $file or die qq{Could not open "$file": $!\n};
+	my $slurp;
+	{ local $/; $slurp = <$fh> }
+	$slurp =~ s/^\$VERSION = '\d+\.\d+\.\d+'.+?\n//gm;
+	seek $fh, 0, 0;
+	print $fh $slurp;
+	truncate $fh, tell($fh);
+	close $fh or die qq{Could not close "$file": $!\n};
+
+} ## end of restore_self_version
 
 sub reset_path {
 
-- 
1.6.0.5



More information about the Check_postgres mailing list