File: 24-only-report-warnings.t

package info (click to toggle)
libtest-warnings-perl 0.038-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 472 kB
  • sloc: perl: 375; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 805 bytes parent folder | download
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
use strict;
use warnings;

my $has_test_tester;
BEGIN { $has_test_tester = eval { require Test::Tester; Test::Tester->VERSION(0.108); 1 } }

use Test::More 0.88;
plan skip_all => 'These tests require Test::Tester 0.108' if not $has_test_tester;
plan tests => 1;

use if "$]" >= '5.008', lib => 't/lib';
use if "$]" >= '5.008', 'SilenceStderr';

$ENV{PERL_TEST_WARNINGS_ONLY_REPORT_WARNINGS} = 1;
use Test::Warnings qw(had_no_warnings :report_warnings :no_end_test);
Test::Warnings::_builder(my $capture = Test::Tester::capture());

warn 'this is a warning 1 2 3'; my $line = __LINE__;

my (undef, @results) = Test::Tester::run_tests(sub { had_no_warnings; });

Test::Tester::cmp_results(
    [ $capture->details ],
    [ ],
    'with "PERL_TEST_WARNINGS_ONLY_REPORT_WARNINGS" set, test does not fail',
);