Re: [PATCH 09/19] tests: use test_write_lines() to generate line-oriented output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Dec 09, 2021 at 12:11:05AM -0500, Eric Sunshine wrote:

> Take advantage of test_write_lines() to generate line-oriented output
> rather than using for-loops or a series of `echo` commands. Not only is
> test_write_lines() a natural fit for such a task, but there is less
> opportunity for a broken &&-chain.

Makes sense. A few of these append like this:

> -	for w in Some extra lines here; do echo $w; done >>one &&
> +	test_write_lines Some extra lines here >>one &&

which made me wonder if the original really wanted to append, or if they
meant:

  for w in Some extra lines here; do echo $w >>one; done

in the first place. In which case you could write ">one". But in the
cases I peeked at, they really are appending to a file that already
existed. And at any rate, your conversions are all faithful to the
original, which is the right thing to do to avoid introducing bugs.

>  test_expect_success 'color new trailing blank lines' '
> -	{ echo a; echo b; echo; echo; } >x &&
> +	test_write_lines a b "" "" >x &&
>  	git add x &&
> -	{ echo a; echo; echo; echo; echo c; echo; echo; echo; echo; } >x &&
> +	test_write_lines a "" "" "" c "" "" "" "" >x &&

Some of these I think might be more readable as here-docs. But I think
keeping to the minimal change here makes sense (and I admit I do not
overly care much either way; it was just on my mind from the last
patch).

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux