File: ack-invalid-ackrc.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 (90 lines) | stat: -rw-r--r-- 2,224 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!perl -T

use strict;
use warnings;

use File::Temp;
use List::Util qw(sum);
use Test::More;
use lib 't';
use Util;

plan skip_all => q{Don't yet have a reliable way to ignore the Unicode complaints from Pod::Perldoc};

my @types = (
    perl   => [qw{.pl .pod .pl .t}],
    python => [qw{.py}],
    ruby   => [qw{.rb Rakefile}],
);

plan tests => sum(map { ref($_) ? scalar(@$_) : 1 } @types) + 14;

prep_environment();

my $wd = getcwd_clean();

my $tempdir = File::Temp->newdir;

safe_chdir( $tempdir->dirname );
write_file '.ackrc', "--frobnicate\n";

my $output;

$output = run_ack( '--env', '--help' );
like $output, qr/Usage: ack/;

{
    my $stderr;

    ( $output, $stderr ) = run_ack_with_stderr( '--env', '--help-types' );
    like join("\n", @{$output}), qr/Usage: ack/;

    $stderr = join("\n", @{$stderr});
    like $stderr, qr/Unknown option: frobnicate/;

    # the following was shamelessly copied from ack-help-types.t
    for (my $i = 0; $i < @types; $i += 2) {
        my ( $type, $checks ) = @types[ $i , $i + 1 ];

        my ( $matching_line ) = grep { /--\[no\]$type/ } @{$output};

        ok $matching_line;

        foreach my $check (@{$checks}) {
            like $matching_line, qr/\Q$check\E/;
        }
    }
}

{
    ($output, my $stderr) = run_ack_with_stderr( '--env', '--man' );
    # Don't worry if man complains about long lines,
    # or if the terminal doesn't handle Unicode:
    is( scalar(grep !m{can't\ break\ line
                     |Wide\ character\ in\ print
                     |Unknown\ escape\ E<0x[[:xdigit:]]+>}x, @{$stderr}),
        0,
        'Should have no output to stderr: ack --env --man' )
        or diag( join( "\n", 'STDERR:', @{$stderr} ) );

    if ( is_windows() ) {
        like( join("\n", @{$output}[0,1]), qr/^NAME\s+ack(?:-standalone)?\s/ );
    }
    else {
        like( $output->[0], qr/ACK(?:-STANDALONE)?\Q(1)\E/ );
    }
}

$output = run_ack( '--env', '--thpppt' );
like( $output, qr/ack --thpppt/ );

$output = run_ack( '--env', '--bar' );
like( $output, qr/It's a grep/ );

$output = run_ack( '--env', '--cathy' );
like $output, qr/CHOCOLATE/;

$output = run_ack( '--env', '--version' );
like $output, qr/ack 2[.]\d+/;

safe_chdir( $wd );