File Coverage

File:expect-collator.pl
Coverage:90.7%

linestmtbrancondsubtimecode
1#!/usr/bin/env -S perl
2
3
3
3
3
3210
4
1825
use warnings;
4
5
3
123146
my ($collated, $notes) = @ARGV;
6
3
3
my @words;
7
3
47
open EXPECT, '<', $collated;
8
3
28
while (<EXPECT>) {
9
4
5
  chomp;
10
4
13
  next unless /(.*) \((.*)\)/;
11
2
4
  my ($key, $list) = ($1, $2);
12
2
5
  my @variants = split /, /, $list;
13
2
4
3
4
  @variants = grep { $_ ne $key } @variants;
14
2
6
  push @words, @variants;
15}
16
3
7
close EXPECT;
17
3
2
5
5
my $pattern = '\`(?:'.join('|', map { quotemeta($_) } @words).')`';
18
3
12
open SOURCES, '<', $notes;
19
3
40
while (<SOURCES>) {
20
8
22
  if ($_ =~ /$pattern/) {
21
2
1
    $print = 0;
22
2
5
    $print = 1 if s/not a recognized word/ignored by check-spelling because another more general variant is also in expect/;
23
2
6
    $print = 1 if s/unrecognized-spelling/ignored-expect-variant/;
24
2
2
    next unless $print;
25  } else {
26
6
13
    next unless /\(((?:\w+-)+\w+)\)$/;
27
6
9
    next if $1 eq 'unrecognized-spelling';
28  }
29
4
12
  print;
30}
31
3
0
close SOURCES;