File: process-substitution.t

package info (click to toggle)
ack 2.24-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,704 kB
  • sloc: perl: 8,590; ansic: 21; fortran: 11; makefile: 5; sh: 5
file content (64 lines) | stat: -rw-r--r-- 1,151 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!perl -T

use strict;
use warnings;
use lib 't';

use Test::More;
use Util;

my @expected = (
    'THIS IS ALL IN UPPER CASE',
    'this is a word here',
);

prep_environment();

if ( is_windows() ) {
    plan skip_all => 'Test unreliable on Windows.';
}

system 'bash', '-c', 'exit';
if ( $? ) {
    plan skip_all => 'You need bash to run this test';
    exit;
}

plan tests => 1;

my ( $read, $write );

pipe( $read, $write );

my $pid = fork();

my @output;

if ( $pid ) {
    close $write;
    while(<$read>) {
        chomp;
        push @output, $_;
    }
    waitpid $pid, 0;
}
else {
    close $read;
    open STDOUT, '>&', $write or die "Can't open: $!";
    open STDERR, '>&', $write or die "Can't open: $!";

    my @args = build_ack_invocation( qw( --noenv --nocolor --smart-case this ) );
    # XXX doing this by hand here eq '=('
    my $perl = caret_X();

    if ( $ENV{'AUTOPKGTEST_TMP'} ) {
        unshift( @args, $perl );
    }
    else {
        unshift( @args, $perl, '-Mblib' );
    }
    my $args = join( ' ', @args );
    exec 'bash', '-c', "$args <(cat t/swamp/options.pl)";
}

lists_match( \@output, \@expected, __FILE__ );