summaryrefslogtreecommitdiff
path: root/src/test/perl/SimpleTee.pm
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-07-09 13:19:10 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-07-09 13:19:10 +0300
commit1ea06203b82b98b5098808667f6ba652181ef5b2 (patch)
tree9fcae4ae03297ffd07afbe9f90fd83c1e8501064 /src/test/perl/SimpleTee.pm
parent01051a9879fcd353eaf0d3788a911e774b52798c (diff)
Improve logging of TAP tests.
Create a log file for each test run. Stdout and stderr of the test script, as well as any subprocesses run as part of the test, are redirected to the log file. This makes it a lot easier to debug test failures. Also print the test output (ok 12 - ... messages) to the log file, and the command line of any external programs executed with the system_or_bail and run_log functions. This makes it a lot easier to debug failing tests. Modify some of the pg_ctl and other command invocations to not use 'silent' or 'quiet' options, and don't redirect output to /dev/null, so that you get all the information in the log instead. In the passing, construct some command lines in a way that works if $tempdir contains quote-characters. I haven't systematically gone through all of them or tested that, so I don't know if this is enough to make that work. pg_rewind tests had a custom mechanism for creating a similar log file. Use the new generic facility instead. Michael Paquier and me.
Diffstat (limited to 'src/test/perl/SimpleTee.pm')
-rw-r--r--src/test/perl/SimpleTee.pm27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/perl/SimpleTee.pm b/src/test/perl/SimpleTee.pm
new file mode 100644
index 00000000000..8d31a4013c8
--- /dev/null
+++ b/src/test/perl/SimpleTee.pm
@@ -0,0 +1,27 @@
+# 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 SimpleTee;
+use strict;
+
+sub TIEHANDLE {
+ my $self = shift;
+ bless \@_, $self;
+}
+
+sub PRINT {
+ my $self = shift;
+ my $ok = 1;
+ for my $fh (@$self) {
+ print $fh @_ or $ok = 0;
+ }
+ return $ok;
+}
+
+1;