File: 06-warnings.t

package info (click to toggle)
libtest-kwalitee-perl 1.28-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 348 kB
  • sloc: perl: 321; makefile: 2
file content (55 lines) | stat: -rw-r--r-- 1,380 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
43
44
45
46
47
48
49
50
51
52
53
54
55
use strict;
use warnings;

use Test::More 0.96;
use Test::Deep;
use Test::Warnings 0.009 ':no_end_test', ':all';

# we explicitly DO want to see warnings here...
delete local @ENV{qw(_KWALITEE_NO_WARN AUTHOR_TESTING RELEASE_TESTING)};

{
    my @warnings = warnings {
        subtest 'no %ENV, running from t/' => sub {
            require Test::Kwalitee;
            Test::Kwalitee->import(tests => [ 'has_tests' ])
        };
    };

    cmp_deeply(
        \@warnings,
        [ "These tests should not be running unless AUTHOR_TESTING=1 and/or RELEASE_TESTING=1!\n" ],
        'warning is issued when there is no environment guard',
    ) or diag 'got warnings: ', explain \@warnings;
}

{
    my @warnings = warnings {
        subtest 'no %ENV, running from xt/' => sub {
            do './xt/warnings.t' or die $@;
        }
    };

    cmp_deeply(
        \@warnings,
        [ ],
        'no warnings issued with no environment guard from an xt/ test',
    ) or diag 'got warnings: ', explain \@warnings;
}

{
    my @warnings = warnings {
        subtest 'kwalitee_ok' => sub {
            do './xt/kwalitee_ok.t' or die $@;
        }
    };

    cmp_deeply(
        \@warnings,
        [ ],
        'no warnings issued with from running kwalitee_ok directly',
    ) or diag 'got warnings: ', explain \@warnings;
}

had_no_warnings if $ENV{AUTHOR_TESTING};
done_testing;