File: 11-redirect-oo.t

package info (click to toggle)
libio-pager-perl 2.10-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 284 kB
  • sloc: perl: 1,416; makefile: 14
file content (36 lines) | stat: -rw-r--r-- 998 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use strict;
use warnings;
use File::Temp;
use Test::More 0.88;
require './t/TestUtils.pm';
t::TestUtils->import();

#Disable warnings for awkard test file mechanism required by Windows
my(undef, $tempname) = do{ $^W=0; File::Temp::tempfile(OPEN=>0)};
END{ close(TMP); unlink $tempname or die "Could not unlink '$tempname': $!" }

#Print the heredoc in 11-redirect.pl to temp file via redirection
system qq($^X t/11-redirect-oo.pl >$tempname);

open(TMP, $tempname) or die "Could not open tmpfile: $!\n";
my $slurp = do{ undef $/; <TMP> };

TODO:{
  local $TODO = '';

  #Special case for CMD & PowerShell lameness, see diag below
  if( $^O =~ /MSWin32/ ){
    $slurp =~ s/\n\n\z/\n/m;
  }

 SKIP:{
    skip_no_tty();

  our $txt; require './t/08-redirect.pl';
  cmp_ok($slurp, 'eq', $txt, 'Redirection with OO') || $^O =~ /MSWin32/ &&
    diag("If this test fails on Windows and all others pass, things are probably good. CMD appends an extra newline to redirected output.");
  }
}


done_testing;