Re: [PATCH v5 10/12] tests: when run in Bash, annotate test failures with file name/line number
- From
Danh Doan <congdanhqx@gmail.com>
- Date
- May 4, 2020, 23:25 UTC
- Message-ID
- <20200504232511.GB29599@danh.dev>
- In-Reply-To
- <20200504174636.GG86805@Carlos-MBP>
On 2020-05-04 10:46:36-0700, Carlo Marcelo Arenas Belón <carenas@gmail.com> wrote:
Show 20 quoted lines
> On Sat, Apr 11, 2020 at 12:18:12AM +0700, Đoàn Trần Công Danh wrote:
> > diff --git a/t/test-lib.sh b/t/test-lib.sh
> > index 0ea1e5a05e..40a00983f7 100644
> > --- a/t/test-lib.sh
> > +++ b/t/test-lib.sh
> > @@ -657,6 +657,18 @@ die () {
> > fi
> > }
> >
> > +file_lineno () {
> > + test -z "$GIT_TEST_FRAMEWORK_SELFTEST" && test -n "$BASH" || return 0
> > + local i
> > + for i in ${!BASH_SOURCE[*]}
>
> this line breaks with NetBSD's sh (and probably other POSIX complaint shells)
>
> the Coding Guidelines mention "no shell arrays" and while the tests are more
> relaxed against that rule, usually workarounds are needed, as it is shown by:
> 5826b7b595 (test-lib: check Bash version for '-x' without using shell arrays,
> 2019-01-03)This function will be called in CI only, and when the the shell used is bash, to annotate the faulty line.
We have a test guarding it already. So, I think it's fine.
-- Danh