File: filter.t

package info (click to toggle)
libipc-filter-perl 0.005-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 96 kB
  • sloc: perl: 101; makefile: 2
file content (53 lines) | stat: -rw-r--r-- 1,090 bytes parent folder | download | duplicates (4)
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
use warnings;
use strict;

use Module::Build 0.2808;
use Test::More;

BEGIN {
	plan skip_all => "these tests rely on Unix commands"
		unless Module::Build->is_unixish;
	plan tests => 14;
	use_ok "IPC::Filter", qw(filter);
}

my($result, $err);

sub test_filter($@) {
	my($data, @cmd) = @_;
	$result = eval { filter($data, @cmd) };
	$err = $@;
}

test_filter("foo\n");
is($err, "filter: invalid command\n");

test_filter("foo\n", "-");
is($err, "filter: invalid command\n");

test_filter("foo\n", "cat");
is($err, "");
is($result, "foo\n");

test_filter("foo\n", "tr", "abfor", "ABFOR");
is($err, "");
is($result, "FOO\n");

test_filter("foo\n", "tr abfor ABFOR");
is($err, "");
is($result, "FOO\n");

test_filter("foo\n", "tr abfor ABFOR; echo bar");
is($err, "");
is($result, "FOO\nbar\n");

test_filter("foo\n", "{ exit 1; }");
is($err, "filter: process exited with status 1\n");

test_filter("foo\n", "echo >&2 bar; exit 1");
is($err, "filter: process exited with status 1\nbar\n");

test_filter("foo\n", "echo >&2 bar; kill -9 \$\$");
is($err, "filter: process died on SIGKILL\n");

1;