| 1 | #!/usr/bin/env perl |
| 2 | |
| 3 | use strict; |
| 4 | use warnings; |
| 5 | |
| 6 | # Assemble expected output for check-greplint target. |
| 7 | # Usage: greplint-cat.pl <outdir> <test-name> ... |
| 8 | # |
| 9 | # For each <test-name>, reads greplint/<test-name>.expect and |
| 10 | # prepends "greplint/<test-name>.test:" to every non-empty line, |
| 11 | # matching the output format of greplint.pl. Writes combined |
| 12 | # expected output to <outdir>/expect. |
| 13 | |
| 14 | my $outdir = shift; |
| 15 | open(my $expect, '>', "$outdir/expect") |
| 16 | or die "unable to open $outdir/expect: $!"; |
| 17 | |
| 18 | for my $name (@ARGV) { |
| 19 | open(my $fh, '<', "greplint/$name.expect") |
| 20 | or die "unable to open greplint/$name.expect: $!"; |
| 21 | while (<$fh>) { |
| 22 | print $expect "greplint/$name.test:$_"; |
| 23 | } |
| 24 | close $fh; |
| 25 | } |
| 26 | |
| 27 | close $expect; |