coreutils
[Top][All Lists]
Advanced

[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 12:41:25 +0200

Bernhard Voelker wrote:
> On 08/22/2012 09:57 AM, Jim Meyering wrote:
>> Bernhard Voelker wrote:
>
>>> Subject: [PATCH] tests: correct print_ver_ arguments
>
>> Nice!
>
> Thanks.
>
>> What do you think about adding a syntax-check to run that script?
>
> Never done before, but below is what seems to work - together
> with the 2 additional fixed tests.
>
> Have a nice day,
> Berny
>
>
>>From ff7e6b4f805c1bfdbb7e050e60428347fea617b9 Mon Sep 17 00:00:00 2001
> From: Bernhard Voelker <address@hidden>
> Date: Wed, 22 Aug 2012 11:39:16 +0200
> Subject: [PATCH] tests: correct print_ver_ arguments and add a rule to
>  enforce this
>
> Some tests have been derived from other tests while
> the argument(s) to print_ver_ have not been adapted.
> Add a new cfg.mk rule to prohibit this.
>
> * cfg.mk (sc_prohibit_test_calls_print_ver_with_irrelevant_argument):
> New rule, to prohit test scripts calling print_env_ for programs not
> actually being used during the test.
> * tests/chown/basic: s/\(print_ver_\) chgrp/\1 chown/
> * tests/cp/acl: s/\(print_ver_\) mv/\1 cp/
> * tests/cp/capability: s/\(print_ver_\) ls/\1 cp/
> * 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/
> ---
>  cfg.mk                        |   16 ++++++++++++++++
>  tests/chown/basic             |    2 +-
>  tests/cp/acl                  |    2 +-
>  tests/cp/capability           |    2 +-
>  tests/cp/cp-parents           |    2 +-
>  tests/du/bind-mount-dir-cycle |    2 +-
>  tests/misc/wc-parallel        |    2 +-
>  7 files changed, 22 insertions(+), 6 deletions(-)
>
> diff --git a/cfg.mk b/cfg.mk
> index 19a84fa..77f10df 100644
> --- a/cfg.mk
> +++ b/cfg.mk
> @@ -329,6 +329,22 @@ sc_some_programs_must_avoid_exit_failure:
>           && { echo '$(ME): do not use EXIT_FAILURE in the above'     \
>                 1>&2; exit 1; } || :
>
> +# Ensure that tests call the print_ver_ function for programs which are
> +# actually used in that test.
> +sc_prohibit_test_calls_print_ver_with_irrelevant_argument:
> +     @git grep -w print_ver_ tests                                   \
> +       | sed 's#:print_ver_##'                                       \
> +       | while read file name; do                                    \
> +           for i in $$name; do                                       \
> +             case "$$i" in install) i=ginstall;; esac;               \
> +             grep -w "$$i" $$file|grep -vw print_ver_|grep -q .      \
> +               || { echo "$(ME): do not call print_ver_ for programs"\
> +                     "not actually being used in this test";         \
> +                    echo "Test: $$file, offending: $$i."             \
> +                    1>&2; exit 1; }                                  \
> +           done;                                                     \
> +         done

Thanks!
When there are two or more offending files, it would be nice
to report all of them before failing.  The above stops at the first.
Other tests set fail=0 before everything, set fail=1 when printing a
line, and print the "echo $(ME): ..." diagnostic at the end, referring
to "the above".



reply via email to

[Prev in Thread] Current Thread [Next in Thread]