Re: [PATCH 2/2] t6402: check exit status of ls-files
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Apr 21, 2021, 17:32 UTC
- Message-ID
- <CAPig+cS4tkXZLPDEWgEytzEOCR7oGrXyg1CZVKVPSXuJOifLjQ@mail.gmail.com>
- In-Reply-To
- <CAPig+cSh6VNpWbGPpTqY0rmw7zf9s-kSXSOMYvW94UHOF7t80w@mail.gmail.com>
On Wed, Apr 21, 2021 at 12:55 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 12 quoted lines
> count_ls_files 5 -s && > count_ls_files 3 -u && > count_ls_files 1 -u one~HEAD && > ... > > The nice thing about having a helper function is that it can clean up > after itself by not leaving a new file lying around, thus you wouldn't > have to make adjustments to the expected number of untracked files (as > mentioned in the commit message). If this is the sort of thing which > comes up often enough (if there are more such cases beyond the two > scripts you changed in this series), then it might make sense to > promote the helper function to test-lib-functions.sh.
The frequency with which this idiom crops up with commands beyond git-ls-files suggests the more general solution of supporting it directly in test-lib-functions.sh for any command. For instance:
test_cmd_line_count = 3 git ls-files -u &&
Or, perhaps, a new mode of test_line_count():
test_line_count = 3 -c git ls-files -u &&