File: 04-stderr.t

package info (click to toggle)
libtest-command-perl 0.11-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 144 kB
  • sloc: perl: 712; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 1,114 bytes parent folder | download | duplicates (5)
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
#!perl

use Test::Command tests => 15;

use Test::More;

use FindBin;

## determine whether we can run perl or not

system qq($^X -e 1) and BAIL_OUT('error calling perl via system');

is( stderr_value(qq($^X -e "print STDERR 'foo'")),
   "foo", "stderr_value is foo");
is( Test::Command::_slurp(stderr_file(qq($^X -e "print STDERR 'foo'"))),
   "foo", "stderr_file contains foo");

stderr_is_eq(qq($^X -e "print STDERR 'foo'"), "foo");

stdout_is_eq(qq($^X -e "print STDERR 'foo'"), "");

stderr_is_eq([$^X, '-e', q(print STDERR 'foo')], 'foo');

stderr_is_eq(qq($^X -e "print 'foo'"), '');

stderr_isnt_eq(qq($^X -e "print STDERR 'foo'"), "bar");

stderr_is_num(qq($^X -e "print STDERR 123"), 123);

stderr_isnt_num(qq($^X -e "print STDERR 321"), 123);

stderr_like(qq($^X -e "print STDERR 'foo'"), qr/fo+/);

stderr_unlike(qq($^X -e "print STDERR 'foo'"), qr/fooo/);

stderr_cmp_ok(qq($^X -e "print STDERR 1"), '<', 2);
stderr_cmp_ok(qq($^X -e "print STDERR 1"), '==', 1);
stderr_cmp_ok(qq($^X -e "print STDERR 1"), 'eq', 1);

stderr_is_file(qq($^X -le "print STDERR qq(bar\nfoo)"), "$FindBin::Bin/stderr.txt");