File Coverage

File:expect-collator.pl
Coverage:93.0%

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