From: Greg Sabino Mullane Date: Thu, 23 Apr 2009 20:16:48 +0000 (-0400) Subject: Funky version modification mojo. X-Git-Tag: 2.9.0~89 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=bf5a2a988b0da148d93b77a415527941a50e211e;p=check_postgres.git Funky version modification mojo. --- diff --git a/t/CP_Testing.pm b/t/CP_Testing.pm index e3918a91c..a0bc04e28 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 {