mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
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.
This commit is contained in:
parent
f46fb819a9
commit
c9c03ea24d
12
cfg.mk
12
cfg.mk
@ -1109,17 +1109,7 @@ spacing-check:
|
|||||||
|
|
||||||
test-wrap-argv:
|
test-wrap-argv:
|
||||||
$(AM_V_GEN)files=`$(VC_LIST) | grep -E '\.(ldargs|args)'`; \
|
$(AM_V_GEN)files=`$(VC_LIST) | grep -E '\.(ldargs|args)'`; \
|
||||||
for file in $$files ; \
|
$(PERL) $(top_srcdir)/tests/test-wrap-argv.pl --check $$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
|
|
||||||
|
|
||||||
# sc_po_check can fail if generated files are not built first
|
# sc_po_check can fail if generated files are not built first
|
||||||
sc_po_check: \
|
sc_po_check: \
|
||||||
|
@ -24,19 +24,30 @@
|
|||||||
#
|
#
|
||||||
# If --in-place is supplied as the first parameter of this script,
|
# If --in-place is supplied as the first parameter of this script,
|
||||||
# the files will be changed in place.
|
# 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.
|
# Otherwise the rewrapped files are printed to the standard output.
|
||||||
|
|
||||||
$in_place = 0;
|
$in_place = 0;
|
||||||
|
$check = 0;
|
||||||
|
|
||||||
if (@ARGV[0] eq "--in-place") {
|
if (@ARGV[0] eq "--in-place") {
|
||||||
$in_place = 1;
|
$in_place = 1;
|
||||||
shift @ARGV;
|
shift @ARGV;
|
||||||
|
} elsif (@ARGV[0] eq "--check") {
|
||||||
|
$check = 1;
|
||||||
|
shift @ARGV;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $file (@ARGV) {
|
foreach my $file (@ARGV) {
|
||||||
&rewrap($file);
|
$ret = 0;
|
||||||
|
if (&rewrap($file) < 0) {
|
||||||
|
$ret = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exit $ret;
|
||||||
|
|
||||||
sub rewrap {
|
sub rewrap {
|
||||||
my $file = shift;
|
my $file = shift;
|
||||||
|
|
||||||
@ -74,11 +85,21 @@ sub rewrap {
|
|||||||
print FILE $line;
|
print FILE $line;
|
||||||
}
|
}
|
||||||
close FILE;
|
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 {
|
} else {
|
||||||
foreach my $line (@lines) {
|
foreach my $line (@lines) {
|
||||||
print $line;
|
print $line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub rewrap_line {
|
sub rewrap_line {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user