зеркало из https://github.com/microsoft/git.git
test-lib: Replace uses of $(expr ...) by POSIX shell features.
In particular: - Test case counting can be achieved by arithmetic expansion. - The name of the test, e.g. t1234, can be computed with ${0%%} and ${0##}. Signed-off-by: Johannes Sixt <j6t@kdbg.org>
This commit is contained in:
Родитель
5b46a4285f
Коммит
d5d9de1b10
|
@ -242,14 +242,14 @@ test_merge () {
|
||||||
# the text_expect_* functions instead.
|
# the text_expect_* functions instead.
|
||||||
|
|
||||||
test_ok_ () {
|
test_ok_ () {
|
||||||
test_count=$(expr "$test_count" + 1)
|
test_count=$(($test_count + 1))
|
||||||
test_success=$(expr "$test_success" + 1)
|
test_success=$(($test_success + 1))
|
||||||
say_color "" " ok $test_count: $@"
|
say_color "" " ok $test_count: $@"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_failure_ () {
|
test_failure_ () {
|
||||||
test_count=$(expr "$test_count" + 1)
|
test_count=$(($test_count + 1))
|
||||||
test_failure=$(expr "$test_failure" + 1);
|
test_failure=$(($test_failure + 1))
|
||||||
say_color error "FAIL $test_count: $1"
|
say_color error "FAIL $test_count: $1"
|
||||||
shift
|
shift
|
||||||
echo "$@" | sed -e 's/^/ /'
|
echo "$@" | sed -e 's/^/ /'
|
||||||
|
@ -257,13 +257,13 @@ test_failure_ () {
|
||||||
}
|
}
|
||||||
|
|
||||||
test_known_broken_ok_ () {
|
test_known_broken_ok_ () {
|
||||||
test_count=$(expr "$test_count" + 1)
|
test_count=$(($test_count+1))
|
||||||
test_fixed=$(($test_fixed+1))
|
test_fixed=$(($test_fixed+1))
|
||||||
say_color "" " FIXED $test_count: $@"
|
say_color "" " FIXED $test_count: $@"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_known_broken_failure_ () {
|
test_known_broken_failure_ () {
|
||||||
test_count=$(expr "$test_count" + 1)
|
test_count=$(($test_count+1))
|
||||||
test_broken=$(($test_broken+1))
|
test_broken=$(($test_broken+1))
|
||||||
say_color skip " still broken $test_count: $@"
|
say_color skip " still broken $test_count: $@"
|
||||||
}
|
}
|
||||||
|
@ -279,12 +279,10 @@ test_run_ () {
|
||||||
}
|
}
|
||||||
|
|
||||||
test_skip () {
|
test_skip () {
|
||||||
this_test=$(expr "./$0" : '.*/\(t[0-9]*\)-[^/]*$')
|
|
||||||
this_test="$this_test.$(expr "$test_count" + 1)"
|
|
||||||
to_skip=
|
to_skip=
|
||||||
for skp in $GIT_SKIP_TESTS
|
for skp in $GIT_SKIP_TESTS
|
||||||
do
|
do
|
||||||
case "$this_test" in
|
case $this_test.$(($test_count+1)) in
|
||||||
$skp)
|
$skp)
|
||||||
to_skip=t
|
to_skip=t
|
||||||
esac
|
esac
|
||||||
|
@ -292,7 +290,7 @@ test_skip () {
|
||||||
case "$to_skip" in
|
case "$to_skip" in
|
||||||
t)
|
t)
|
||||||
say_color skip >&3 "skipping test: $@"
|
say_color skip >&3 "skipping test: $@"
|
||||||
test_count=$(expr "$test_count" + 1)
|
test_count=$(($test_count+1))
|
||||||
say_color skip "skip $test_count: $1"
|
say_color skip "skip $test_count: $1"
|
||||||
: true
|
: true
|
||||||
;;
|
;;
|
||||||
|
@ -370,7 +368,7 @@ test_external () {
|
||||||
then
|
then
|
||||||
# Announce the script to reduce confusion about the
|
# Announce the script to reduce confusion about the
|
||||||
# test output that follows.
|
# test output that follows.
|
||||||
say_color "" " run $(expr "$test_count" + 1): $descr ($*)"
|
say_color "" " run $(($test_count+1)): $descr ($*)"
|
||||||
# Run command; redirect its stderr to &4 as in
|
# Run command; redirect its stderr to &4 as in
|
||||||
# test_run_, but keep its stdout on our stdout even in
|
# test_run_, but keep its stdout on our stdout even in
|
||||||
# non-verbose mode.
|
# non-verbose mode.
|
||||||
|
@ -613,7 +611,8 @@ test_create_repo "$test"
|
||||||
# in subprocesses like git equals our $PWD (for pathname comparisons).
|
# in subprocesses like git equals our $PWD (for pathname comparisons).
|
||||||
cd -P "$test" || exit 1
|
cd -P "$test" || exit 1
|
||||||
|
|
||||||
this_test=$(expr "./$0" : '.*/\(t[0-9]*\)-[^/]*$')
|
this_test=${0##*/}
|
||||||
|
this_test=${this_test%%-*}
|
||||||
for skp in $GIT_SKIP_TESTS
|
for skp in $GIT_SKIP_TESTS
|
||||||
do
|
do
|
||||||
to_skip=
|
to_skip=
|
||||||
|
|
Загрузка…
Ссылка в новой задаче