File Coverage

File:expect-collator.pl
Coverage:90.7%

linestmtbrancondsubtimecode
1#!/usr/bin/env -S perl
2
3
3
3
3
3538
3
1854
use warnings;
4
5
3
134872
my ($collated, $notes) = @ARGV;
6
3
2
my @words;
7
3
36
open EXPECT, '<', $collated;
8
3
29
while (<EXPECT>) {
9
4
7
  chomp;
10
4
8
  next unless /(.*) \((.*)\)/;
11
2
4
  my ($key, $list) = ($1, $2);
12
2
4
  my @variants = split /, /, $list;
13
2
4
2
5
  @variants = grep { $_ ne $key } @variants;
14
2
7
  push @words, @variants;
15}
16
3
21
close EXPECT;
17
3
2
4
3
my $pattern = '\`(?:'.join('|', map { quotemeta($_) } @words).')`';
18
3
22
open SOURCES, '<', $notes;
19
3
28
while (<SOURCES>) {
20
8
23
  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
4
    $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
11
    next if $1 eq 'unrecognized-spelling';
28  }
29
4
15
  print;
30}
31
3
0
close SOURCES;