[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] tests: correct print_ver_ arguments
From: |
Jim Meyering |
Subject: |
Re: [PATCH] tests: correct print_ver_ arguments |
Date: |
Wed, 22 Aug 2012 09:57:39 +0200 |
Bernhard Voelker wrote:
> I noticed (too late) that the new tests/du/bind-mount-dir-cycle
> calls print_ver_ with rm as argument instead of du.
> A little script found other wrong uses, too.
...
> Subject: [PATCH] tests: correct print_ver_ arguments
>
> Some tests have been derived from other tests while
> the argument(s) to print_ver_ have not been adapted.
>
> The following snippet found the wrong ones:
>
> grep print_ver_ $(git ls-files | grep ^tests) \
> | sed 's#:print_ver_##' \
> | grep -v '\.log' \
> | while read a b ; do
> for i in $b ; do
> grep -q "$i " $a ||
> echo Test: $a, args: $b, offending: $i
> done
> done
>
> * tests/chown/basic: s/\(print_ver_\) chgrp/\1 chown/
> * tests/cp/cp-parents: s/(print_ver_\) mv/\1 cp/
> * tests/du/bind-mount-dir-cycle: s/(print_ver_\) rm/\1 du/
> * tests/misc/wc-parallel: s/(print_ver_\) md5sum/\1 wc/
Nice!
Thanks for doing that.
What do you think about adding a syntax-check to run that script?
Here's a variant of your script:
#!/bin/sh
git grep -w print_ver_ tests \
| sed 's#:print_ver_##' \
| while read file names; do \
for i in $names; do \
case $i in install) i=ginstall;; esac; \
grep -w "$i" $file|grep -vw print_ver_|grep -q . \
|| echo Test: $file, args: $names, offending: $i; \
done; \
done
That new version is slightly more efficient (no need for git ls-files)
and catches two more offenders by using the tighter grep -w and filtering
out print_ver_ lines:
Test: tests/chown/basic, args: chgrp, offending: chgrp
Test: tests/cp/acl, args: mv getfacl setfacl, offending: mv
It also handles the special case of install that we test via the
"ginstall" name.