mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Move Perl test modules to a better namespace
The five modules in our TAP test framework all had names in the top level namespace. This is unwise because, even though we're not exporting them to CPAN, the names can leak, for example if they are exported by the RPM build process. We therefore move the modules to the PostgreSQL::Test namespace. In the process PostgresNode is renamed to Cluster, and TestLib is renamed to Utils. PostgresVersion becomes simply PostgreSQL::Version, to avoid possible confusion about what it's the version of. Discussion: https://postgr.es/m/aede93a4-7d92-ef26-398f-5094944c2504@dunslane.net Reviewed by Erik Rijkers and Michael Paquier
This commit is contained in:
35
src/test/perl/PostgreSQL/Test/SimpleTee.pm
Normal file
35
src/test/perl/PostgreSQL/Test/SimpleTee.pm
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
# Copyright (c) 2021, PostgreSQL Global Development Group
|
||||
|
||||
# A simple 'tee' implementation, using perl tie.
|
||||
#
|
||||
# Whenever you print to the handle, it gets forwarded to a list of
|
||||
# handles. The list of output filehandles is passed to the constructor.
|
||||
#
|
||||
# This is similar to IO::Tee, but only used for output. Only the PRINT
|
||||
# method is currently implemented; that's all we need. We don't want to
|
||||
# depend on IO::Tee just for this.
|
||||
|
||||
package PostgreSQL::Test::SimpleTee;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub TIEHANDLE
|
||||
{
|
||||
my $self = shift;
|
||||
return bless \@_, $self;
|
||||
}
|
||||
|
||||
sub PRINT
|
||||
{
|
||||
my $self = shift;
|
||||
my $ok = 1;
|
||||
for my $fh (@$self)
|
||||
{
|
||||
print $fh @_ or $ok = 0;
|
||||
$fh->flush or $ok = 0;
|
||||
}
|
||||
return $ok;
|
||||
}
|
||||
|
||||
1;
|
Reference in New Issue
Block a user