Debian Codegraph @

t/passing-todos.t

raw
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use if $ENV{AUTOMATED_TESTING}, 'Test::DiagINC'; use Test::More tests => 6;
6 use TAP::Harness;
7 use IO::Scalar;
8
9 ###############################################################################
10 # TEST: passing TODOs are normally treated as failure condition.
11 passing_todo_default_fail: {
12 my $results = undef;
13 my $fh = IO::Scalar->new(\$results);
14 my $harness = TAP::Harness->new( {
15 formatter_class => 'TAP::Formatter::JUnit',
16 stdout => $fh,
17 } );
18 $harness->runtests('t/data/tests/todo');
19
20 ok $results, 'Ran test with passing TODO';
21 like $results, qr/<testsuite[^>]+errors="1"/, '... with one error';
22 like $results, qr/TodoTestSucceeded/, '... passing TODO';
23 }
24
25 ###############################################################################
26 # TEST: over-ride allows for passing TODOs to be treated as a pass.
27 passing_todo_ok: {
28 local $ENV{ALLOW_PASSING_TODOS} = 1;
29
30 my $results = undef;
31 my $fh = IO::Scalar->new(\$results);
32 my $harness = TAP::Harness->new( {
33 formatter_class => 'TAP::Formatter::JUnit',
34 stdout => $fh,
35 } );
36 $harness->runtests('t/data/tests/todo');
37
38 ok $results, 'Re-ran test with passing TODO';
39 like $results, qr/<testsuite[^>]+errors="0"/, '... with NO errors';
40 unlike $results, qr/TodoTestSucceeded/, '... passing TODO was OK';
41 }