File: 90-output.t

package info (click to toggle)
libsystem-command-perl 1.122-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 228 kB
  • sloc: perl: 550; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 1,135 bytes parent folder | download | duplicates (5)
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
use warnings;
use strict;
use Test::More;

BEGIN {
    if ( !eval 'use Test::Output; 1;' ) {
        $ENV{RELEASE_TESTING}
            ? die "Test::Output is required for RELEASE_TESTING"
            : plan skip_all => 'Test::Output not available';
    }
}

use System::Command;

sub print_implicit { print "STDOUT\n"; }
sub print_stdout   { print STDOUT "STDOUT\n"; }
sub print_stderr   { print STDERR "STDERR\n"; }

plan tests => 10;

# before
stdout_is( \&print_implicit, "STDOUT\n", 'print' );
stdout_is( \&print_stdout,   "STDOUT\n", 'print STDOUT' );
stderr_is( \&print_stderr, "STDERR\n", 'print STDERR' );

# during
{
    my $cmd = System::Command->new( $^X => qw( -le print+1 ) );
    stdout_is( \&print_implicit, "STDOUT\n", 'print' );
    stdout_is( \&print_stdout,   "STDOUT\n", 'print STDOUT' );
    stderr_is( \&print_stderr, "STDERR\n", 'print STDERR' );

    is( $cmd->stdout->getline, "1\n", 'expected command output' );
    $cmd->close;
}

# after
stdout_is( \&print_implicit, "STDOUT\n", 'print' );
stdout_is( \&print_stdout,   "STDOUT\n", 'print STDOUT' );
stderr_is( \&print_stderr, "STDERR\n", 'print STDERR' );