File: ack-named-pipes.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 (62 lines) | stat: -rw-r--r-- 1,018 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
#!perl -T

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

use File::Temp;
use Test::More;
use Util;
use POSIX ();

local $SIG{'ALRM'} = sub {
    fail 'Timeout';
    exit;
};

prep_environment();

my $tempdir = File::Temp->newdir;
safe_mkdir( "$tempdir/foo" );
my $rc = eval { POSIX::mkfifo( "$tempdir/foo/test.pipe", oct(660) ) };
if ( !$rc ) {
    dir_cleanup( $tempdir );
    plan skip_all => $@ ? $@ : q{I can't run a mkfifo, so cannot run this test.};
}

plan tests => 2;

touch( "$tempdir/foo/bar.txt" );

alarm 5; # Should be plenty of time.

my @results = run_ack( '-f', $tempdir );

is_deeply( \@results, [
    "$tempdir/foo/bar.txt",
], 'Acking should not find the fifo' );

dir_cleanup( $tempdir );

done_testing();

sub dir_cleanup {
    my $tempdir = shift;

    unlink "$tempdir/foo/bar.txt";
    rmdir "$tempdir/foo";
    rmdir $tempdir;

    return;
}


sub touch {
    my $filename = shift;

    my $fh;
    open $fh, '>>', $filename or die "Unable to append to $filename: $!";
    close $fh;

    return;
}