提交 c9c03ea2 编写于 作者: J Ján Tomko

test-wrap-argv: add --check parameter

This script can already operate on a list of files.
Add a --check parameter to check if multiple files are wrapped
correctly with a single invocation of the script.
上级 f46fb819
......@@ -1109,17 +1109,7 @@ spacing-check:
test-wrap-argv:
$(AM_V_GEN)files=`$(VC_LIST) | grep -E '\.(ldargs|args)'`; \
for file in $$files ; \
do \
$(PERL) $(top_srcdir)/tests/test-wrap-argv.pl $$file > $${file}-t ; \
diff $$file $${file}-t; \
res=$$? ; \
rm $${file}-t ; \
test $$res == 0 || { \
echo "$(ME): Incorrect line wrapping in $$file" 1>&2; \
echo "$(ME): Use test-wrap-argv.pl to wrap test data files" 1>&2; \
exit 1; } \
done
$(PERL) $(top_srcdir)/tests/test-wrap-argv.pl --check $$files
# sc_po_check can fail if generated files are not built first
sc_po_check: \
......
......@@ -24,19 +24,30 @@
#
# If --in-place is supplied as the first parameter of this script,
# the files will be changed in place.
# If --check is the first parameter, the script will return
# a non-zero value if a file is not wrapped correctly.
# Otherwise the rewrapped files are printed to the standard output.
$in_place = 0;
$check = 0;
if (@ARGV[0] eq "--in-place") {
$in_place = 1;
shift @ARGV;
} elsif (@ARGV[0] eq "--check") {
$check = 1;
shift @ARGV;
}
foreach my $file (@ARGV) {
&rewrap($file);
$ret = 0;
if (&rewrap($file) < 0) {
$ret = 1;
}
}
exit $ret;
sub rewrap {
my $file = shift;
......@@ -74,11 +85,21 @@ sub rewrap {
print FILE $line;
}
close FILE;
} elsif ($check) {
my $nl = join('', @lines);
my $ol = join('', @orig_lines);
unless ($nl eq $ol) {
print STDERR $ol;
print STDERR "Incorrect line wrapping in $file\n";
print STDERR "Use test-wrap-argv.pl to wrap test data files\n";
return -1;
}
} else {
foreach my $line (@lines) {
print $line;
}
}
return 0;
}
sub rewrap_line {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册