File: warnings-after-done.t

package info (click to toggle)
libtest2-plugin-nowarnings-perl 0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 288 kB
  • sloc: perl: 268; sh: 23; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 747 bytes parent folder | download | duplicates (2)
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
use strict;
use warnings;

use Test2::Require::Module 'IPC::Run3';
use Test2::V0;
use Test2::Plugin::NoWarnings;

use IPC::Run3 qw( run3 );

my $code = <<'EOF';
use Test2::V0;
use Test2::Plugin::NoWarnings;

ok( 1, 'this is fine' );

done_testing();

warn "This should not cause a failure but should be visible\n";
EOF

my ( $stdout, $stderr );
run3(
    [ $^X, '-e', $code ],
    \undef,
    \$stdout,
    \$stderr,
);

unlike(
    $stdout, 'not ok',
    'all tests pass when test warns after done_testing()'
);

is( $?, 0, 'no error from test that warns after done_testing()' );

like(
    $stderr,
    qr/This should not cause a failure but should be visible\n/,
    'warning after done_testing() is seen on stderr output',
);

done_testing();