Re: [PATCHv4 02/15] t4017 (diff-retval): replace manual exit code check with test_expect_code

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

 



Ãvar ArnfjÃrà Bjarmason wrote:
> On Fri, Oct 1, 2010 at 10:23, Jonathan Nieder <jrnieder@xxxxxxxxx> wrote:

>> +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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]