Re: [PATCH] test: optionally print subtest number

Subject: Re: [PATCH] test: optionally print subtest number

Date: Sat, 17 Dec 2011 16:04:53 +0200

To: David Bremner, notmuch@notmuchmail.org

Cc: David Bremner

From: Tomi Ollila


On Tue, 13 Dec 2011 15:56:47 -0400, David Bremner <david@tethera.net> wrote:
> From: David Bremner <bremner@debian.org>
> 
> The idea is that $test_count could be used in tests to label
> intermediate files. The output enabled by this patch (and --debug)
> helps figure out which OUTPUT.nn file belongs to which test in case
> several subtests write to OUTPUT.$test_count
> ---
> 
> Is there something that depends on the test format? I find it pretty
> handy to have the subtest numbers, but I don't want to break some
> other tools. I followed the existing style of conditionally defining
> functions, but maybe someone with more bash-fu can improve that.
> 
>  test/test-lib.sh |   12 ++++++++++++
>  1 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/test/test-lib.sh b/test/test-lib.sh
> index 6be93fe..aaaaf5c 100644
> --- a/test/test-lib.sh
> +++ b/test/test-lib.sh
> @@ -116,6 +116,16 @@ do
>  	esac
>  done
>  
> +if test -n "$debug"; then
> +    print_subtest () {
> +	printf "\t[%d]\t" $(($test_count - 1))

Like this, as iterated by Dmitry & me

	printf " %-4s" "[$(($test_count - 1))]"
(or
	printf " %-4s" "[$((test_count - 1))]"
)

I think this is very useful feature; When searching reasons why
test failed the output files can be easily found as the test
number is show on screen. Also, when debugging problems with 
users online in distant locations, passing around the test
number in any particular moment eases the interaction considerably.

Tomi

Thread: