File: tap-todo

package info (click to toggle)
node-eslint-utils 2.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 436 kB
  • sloc: javascript: 4,224; perl: 39; makefile: 26; sh: 6
file content (107 lines) | stat: -rwxr-xr-x 2,414 bytes parent folder | download | duplicates (3)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/perl

use v5.10;
use utf8;
use strict;
use warnings;
use re 'taint';

use TAP::Parser;

=head1 NAME

tap-todo - TAP filter to tolerate select failures

=head1 VERSION

Version v0.2.1

=cut

our $VERSION = version->declare('v0.2.1');

=head1 SYNOPSIS

B<prove --lib> | B<tap-todo> "B<is a foo>" "B<does.* do bar::reason: baz.*>"

=head1 DESCRIPTION

B<tap-todo> filters the output of TAP tests
and flags select (otherwise) failing tests as TODO.

You feed the original TAP data via STDIN,
and apply skip-patterns for failing tests that should be tolerated.

Each skip-pattern is a regular expression matched against description,
optionally followed by "::" and
a regular expression for YAML data and other subsequent content.

tap-todo fails with error code 1
if TAP contains failing tests not caught by skip-patterns.

=cut

# split and compile regular expressions
my @skip = map {
	my ( $desc, $more ) = split /::/;
	my $desc_re = qr/$desc/  || die;
	my $more_re = qr/$more/s || die if ($more);
	{ desc => $desc_re, more => $more_re }
} @ARGV;

open my $fh, "<&STDIN";
my $parser = TAP::Parser->new( { source => $fh } );

my $more;
my $todo = 0;
while ( my $res = $parser->next ) {
	if ( $res->is_test ) {
		$more = undef;
		unless ( $res->is_ok ) {
			foreach ( grep { $res->description =~ $$_{desc} } @skip ) {
				unless ( $more = $$_{more} ) {
					$todo++;
					print "# TODO: ";
				}
				last;
			}
		}
	}
	elsif ( $more and $res->as_string =~ $more ) {
		$todo++;
		print "# TODO: ";
	}
	say $res->as_string;
}
say "# skipped $todo";
say "# skip-patterns ", 0 + @ARGV;

exit( !!( $parser->tests_run - $parser->passed - $todo ) );

=head1 AUTHOR

Jonas Smedegaard C<< <dr@jones.dk> >>

=head1 COPYRIGHT AND LICENSE

  Copyright © 2020 Jonas Smedegaard

  Copyright © 2020 Purism SPC

This program is free software:
you can redistribute it and/or modify it
under the terms of the GNU General Public License
as published by the Free Software Foundation,
either version 3, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY;
without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.

You should have received a copy
of the GNU General Public License along with this program.
If not, see <https://www.gnu.org/licenses/>.

=cut