File Coverage

File:expect-collator.pl
Coverage:30.2%

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