File: SilenceStderr.pm

package info (click to toggle)
libtest-warnings-perl 0.038-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 472 kB
  • sloc: perl: 375; makefile: 2
file content (17 lines) | stat: -rw-r--r-- 393 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use strict;
use warnings;

# this file is only parsable on 5.8+.

open my $stderr_copy, '>&', STDERR;
close STDERR;
open STDERR, '>', \my $stderr
    or die 'something went wrong when redirecting STDERR';

END {
    Test::More::note 'suppressed STDERR:', $stderr if $stderr;

    close STDERR;
    open STDERR, '>&', $stderr_copy
        or die 'something went wrong when restoring STDERR';
}