[libvirt] [PATCH v2] tests: redo test argv file line wrapping

Martin Kletzander mkletzan at redhat.com
Sat Nov 7 08:10:43 UTC 2015


On Fri, Nov 06, 2015 at 04:32:54PM +0000, Daniel P. Berrange wrote:
>Back in
>
>  commit bd6c46fa0cfe275c24debc1152cfc5206c04b59b
>  Author: Juerg Haefliger <juerg.haefliger at hp.com>
>  Date:   Mon Jan 31 06:42:57 2011 -0500
>
>    tests: handle backspace-newline pairs in test input files
>
>all the test argv files were line wrapped so that the args
>were less than 80 characters.
>
>The way the line wrapping was done turns out to be quite
>undesirable, because it often leaves multiple parameters
>on the same line. If we later need to add or remove
>individual parameters, then it leaves us having to redo
>line wrapping.
>
>This commit changes the line wrapping so that every
>single "-param value" is one its own new line. If the
>"value" is still too long, then we break on ',' or ':'
>or ' ' as needed.
>
>This means that when we come to add / remove parameters
>from the test files line, the patch diffs will only
>ever show a single line added/removed which will greatly
>simplify review work.
>
>Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
>---
> cfg.mk                                             |  16 ++-
> .../bhyvexml2argvdata/bhyvexml2argv-acpiapic.args  |  10 +-
> .../networkxml2firewalldata/nat-default-linux.args | 137 ++++++++++++++++-----
> .../qemuxml2argv-aarch64-aavmf-virtio-mmio.args    |  33 +++--
> tests/test-wrap-argv.pl                            | 106 ++++++++++++++++
> 5 files changed, 262 insertions(+), 40 deletions(-)
> create mode 100644 tests/test-wrap-argv.pl
>
>Changed in v2:
>
> - Added hook in syntax-check to run test-wrap-argv
>   to validate files
>
>diff --git a/cfg.mk b/cfg.mk
>index a9bba38..db513be 100644
>--- a/cfg.mk
>+++ b/cfg.mk
>@@ -1068,7 +1068,7 @@ _autogen:
>
> # regenerate HACKING as part of the syntax-check
> ifneq ($(_gl-Makefile),)
>-syntax-check: $(top_srcdir)/HACKING bracket-spacing-check
>+syntax-check: $(top_srcdir)/HACKING bracket-spacing-check test-wrap-argv
> endif
>
> bracket-spacing-check:
>@@ -1077,6 +1077,20 @@ bracket-spacing-check:
> 	  { echo '$(ME): incorrect formatting, see HACKING for rules' 1>&2; \
> 	    exit 1; }
>
>+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; \

Similarly to the check we do with pdwtags, the diff could be printed
as a hint to the user how to fix it nicely, but that's not necessary.

ACK either way.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20151107/2dcbb764/attachment-0001.sig>


More information about the libvir-list mailing list