coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] tests: use "returns_" rather than explicit comparison with "


From: Bernhard Voelker
Subject: Re: [PATCH] tests: use "returns_" rather than explicit comparison with "$?"
Date: Sun, 13 Nov 2016 18:24:00 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

On 11/13/2016 03:38 AM, Jim Meyering wrote:
> I noticed many tests that compare directly with "$?". However, we now
> have the "returns_" function (from init.sh) that can be used to make
> the resulting code a little less error-prone: all on one line/stmt, it
> is harder to accidentally insert code that accidentally clobbers "$?".
> 
> Here's an example of what most of these changes look like:
> 
>   -ls -l --time-style=XX > out 2> err
>   -test $? = 2 || fail=1
>   +returns_ 2 ls -l --time-style=XX > out 2> err || fail=1

Nice work, thanks!

BTW: what was your search pattern?  I mean, is there a reason
you left places like the following alone?


  $ git grep -B1 -F '$? = ' -- tests
  ..
  tests/misc/stdbuf.sh-stdbuf -ol true # Capital 'L' required
  tests/misc/stdbuf.sh:test $? = 125 || fail=1 # Internal error is a particular 
status
  ..

  $ git grep -B1 -F '$? != ' -- tests
  tests/du/8gb.sh-dd bs=1 seek=8G of=big < /dev/null 2> /dev/null
  tests/du/8gb.sh:if test $? != 0; then
  ..


Furthermore, we need to tweak a syntax-check, see attached.

Thanks & have a nice day,
Berny

Attachment: 0001-maint-add-returns_-to-exclude-list-in-sc_prohibit_an.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]