Re: [PATCHv4 02/15] t4017 (diff-retval): replace manual exit code check with test_expect_code
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Oct 1, 2010, 11:52 UTC
- Message-ID
- <20101001115224.GB18405@burratino>
- In-Reply-To
- <AANLkTinqVTqxiHL5tEv+-SS6YURGUoWaPxCgpccZgjEq@mail.gmail.com>
Ævar Arnfjörð Bjarmason wrote:
> On Fri, Oct 1, 2010 at 10:23, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 10 quoted lines
>> +check_exit_status () {
>> + echo "$1" >expect.status
>> + shift
>> + "$@"
>> + echo "$?" >actual.status
>> + test_cmp expect.status actual.status
>> +}
>
> If we add this it should be in the test-lib.sh, it'll probably be
> useful for other tests.FWIW a more generally useful function would have to look something like this:
test_exit_status () {
want_code=$1
shift
"$@"
exit_code=$?
if test $exit_code = $want_code
then
return 0
else
echo >&2 "test_exit_status $want_code: command had status $exit_code: $*"
return 1
fi
}to avoid touching the file system.
> and > change the tests using test_expect_code in t1504-ceiling-dirs.sh and > t6020-merge-df.sh to use test_expect_success + test_expect_code.
Not a bad thing to do anyway.