File: continuation_lines.t

package info (click to toggle)
libnagios-object-perl 0.21.20-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,032 kB
  • sloc: perl: 3,198; makefile: 9
file content (44 lines) | stat: -r--r--r-- 1,114 bytes parent folder | download | duplicates (6)
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
#!/usr/local/bin/perl

use strict;
use warnings;
use Test::More tests => 9;
use Test::NoWarnings;
use File::Temp;
use lib qw( ../lib ./lib );

use_ok('Nagios::Object::Config');

my $cfg_file = File::Temp->new( UNLINK => 0, );

# NOTE: there are spaces and tabs in the following section
print $cfg_file <<'EOF';
define command {
    command_name    long-command
    command_line    /usr/bin/longcommand \
        -options=many \
		-uses=continuation-lines
}
EOF

$cfg_file->close;

my $parser
    = Nagios::Object::Config->new( Version => 2, regexp_matching => 1 );

isa_ok( $parser, 'Nagios::Object::Config' );

ok( $parser->parse( $cfg_file->filename ), 'parse ran OK' );

my $cmds = $parser->list_commands;
ok( $cmds, 'non-null list_commands' );
is( ref($cmds),         'ARRAY', 'Got expected arrayref' );
is( scalar( @{$cmds} ), 1,       'Got correct array count' );

is( $cmds->[0]->command_name, 'long-command', 'command_name set correctly' );
is( $cmds->[0]->command_line,
    '/usr/bin/longcommand -options=many -uses=continuation-lines',
    'command_line set correctly'
);

unlink( $cfg_file->filename );