File: autoflush.t

package info (click to toggle)
libipc-run-perl 20231003.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 844 kB
  • sloc: perl: 6,255; makefile: 5
file content (42 lines) | stat: -rw-r--r-- 1,422 bytes parent folder | download | duplicates (2)
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
37
38
39
40
41
42
use strict;
use warnings;

use IPC::Run;
use Test::More tests => 4;

if ( $^O !~ /Win32/ ) {
    STDOUT->autoflush();
    my $flush = sprintf( "AUTOFLUSH %s: %d", select, $| );
    is( $flush, "AUTOFLUSH main::STDOUT: 1", "Autoflush set" );

    IPC::Run::run( [ $^X, '-V' ], '1>', "/dev/null", '2>', "/dev/null" );

    $flush = sprintf( "AUTOFLUSH %s: %d", select, $| );
    is( $flush, "AUTOFLUSH main::STDOUT: 1", "Autoflush still set" );

    STDOUT->autoflush(0);
    $flush = sprintf( "AUTOFLUSH %s: %d", select, $| );
    is( $flush, "AUTOFLUSH main::STDOUT: 0", "Autoflush unset" );

    IPC::Run::run( [ $^X, '-V' ], '1>', "/dev/null", '2>', "/dev/null" );

    $flush = sprintf( "AUTOFLUSH %s: %d", select, $| );
    is( $flush, "AUTOFLUSH main::STDOUT: 0", "Autoflush still unset" );
}
else {
    my $flush = sprintf( "AUTOFLUSH %s: %d", select, $| );
    is( $flush, "AUTOFLUSH main::STDOUT: 1", "Autoflush set" );

    IPC::Run::run( [ $^X, '-V' ], '1>', "/dev/null", '2>', "/dev/null" );

    $flush = sprintf( "AUTOFLUSH %s: %d", select, $| );
    is( $flush, "AUTOFLUSH main::STDOUT: 1", "Autoflush still set" );

    { local $TODO = 'Seems to work on at least Strawberry Perl 5.20.0';
    STDOUT->autoflush(0);
    $flush = sprintf( "AUTOFLUSH %s: %d", select, $| );
    is( $flush, "AUTOFLUSH main::STDOUT: 1", "Unseting Autoflush on Windows doesn't work" );
    }

    pass('Finished Windows test');
}