Re: [PATCH 09/19] tests: use test_write_lines() to generate line-oriented output
- From
Jeff King <peff@peff.net>
- Date
- Dec 10, 2021, 09:22 UTC
- Message-ID
- <YbMcYwj/Mvf/PoFF@coredump.intra.peff.net>
- In-Reply-To
- <20211209051115.52629-10-sunshine@sunshineco.com>
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.
Show 6 quoted lines
> 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