File: ack-type-del.t

package info (click to toggle)
ack 3.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,636 kB
  • sloc: perl: 10,139; ansic: 21; fortran: 11; makefile: 5; javascript: 3
file content (47 lines) | stat: -rw-r--r-- 1,577 bytes parent folder | download | duplicates (3)
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
#!perl

use strict;
use warnings;

use Test::More tests => 12;
use lib 't';
use Util;

prep_environment();

my ( $stdout, $stderr );
my $help_types_output;

# sanity check
( $stdout, $stderr ) = run_ack_with_stderr('-t', 'perl', '-f', 't/swamp');
is( scalar(@{$stdout}), 12, 'Found initial 11 files' );
is_empty_array( $stderr, 'Nothing in stderr' );

( $stdout, $stderr ) = run_ack_with_stderr('--type-del=perl', '--type-del=perltest', '-t', 'perl', '-f', 't/swamp');
is_empty_array( $stdout, 'Nothing in stdout' );
first_line_like( $stderr, qr/Unknown type 'perl'/ );

( $stdout, $stderr ) = run_ack_with_stderr('--type-del=perl', '--type-del=perltest',  '--type-add=perl:ext:pm', '-t', 'perl', '-f', 't/swamp');
is( scalar(@{$stdout}), 1, 'Got one output line' );
is_empty_array( $stderr, 'Nothing in stderr' );

# more sanity checking
$help_types_output = run_ack( '--help-types' );
like( $help_types_output, qr/\Qperl/ );

$help_types_output = run_ack( '--type-del=perl', '--type-del=perltest', '--help-types' );
unlike( $help_types_output, qr/\Qperl/ );

DUMP: {
    my @dump_output = run_ack( '--type-del=perl', '--type-del=perltest', '--dump' );
    # discard everything up to the ARGV section
    while ( @dump_output && $dump_output[0] ne 'ARGV' ) {
        shift @dump_output;
    }
    shift @dump_output; # discard ARGV
    shift @dump_output; # discard header
    foreach my $line (@dump_output) {
        $line =~ s/^\s+|\s+$//g;
    }
    lists_match( \@dump_output, ['--type-del=perl', '--type-del=perltest'], '--type-del should show up in --dump output' );
}