Skip to content

Commit bb9e465

Browse files
pks-tgitster
authored andcommitted
t: prepare execution of potentially failing commands for set -e
Several of our tests verify whether a certain binary can be executed, potentially skipping tests in case we cannot, for example because the binary doesn't exist. In those cases we often run the binary outside of any conditionally. This will start to fail once we enable `set -e`, as that will cause us to bail out the test immediately. Improve these tests by executing them inside of a conditional instead. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent c17b1a1 commit bb9e465

7 files changed

Lines changed: 12 additions & 14 deletions

t/lib-git-svn.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ GIT_SVN_DIR=$GIT_DIR/svn/refs/remotes/git-svn
1515
SVN_TREE=$GIT_SVN_DIR/svn-tree
1616
test_set_port SVNSERVE_PORT
1717

18-
svn >/dev/null 2>&1
19-
if test $? -ne 1
18+
if ! svn help >/dev/null 2>&1
2019
then
2120
skip_all='skipping git svn tests, svn not found'
2221
test_done

t/lib-httpd.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,10 @@ start_httpd() {
235235

236236
test_atexit stop_httpd
237237

238-
"$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
238+
if ! "$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
239239
-f "$TEST_PATH/apache.conf" $HTTPD_PARA \
240240
-c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start \
241241
>&3 2>&4
242-
if test $? -ne 0
243242
then
244243
cat "$HTTPD_ROOT_PATH"/error.log >&4 2>/dev/null
245244
test_skip_or_die GIT_TEST_HTTPD "web server setup failed"

t/t9200-git-cvsexportcommit.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ if ! test_have_prereq PERL; then
1111
test_done
1212
fi
1313

14-
cvs >/dev/null 2>&1
15-
if test $? -ne 1
14+
if ! cvs version >/dev/null 2>&1
1615
then
1716
skip_all='skipping git cvsexportcommit tests, cvs not found'
1817
test_done

t/t9400-git-cvsserver-server.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ if ! test_have_prereq PERL; then
1717
skip_all='skipping git cvsserver tests, perl not available'
1818
test_done
1919
fi
20-
cvs >/dev/null 2>&1
21-
if test $? -ne 1
20+
21+
if ! cvs version >/dev/null 2>&1
2222
then
2323
skip_all='skipping git-cvsserver tests, cvs not found'
2424
test_done
2525
fi
26+
2627
perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
2728
skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable'
2829
test_done

t/t9401-git-cvsserver-crlf.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ check_status_options() {
6060
return $stat
6161
}
6262

63-
cvs >/dev/null 2>&1
64-
if test $? -ne 1
63+
if ! cvs version >/dev/null 2>&1
6564
then
6665
skip_all='skipping git-cvsserver tests, cvs not found'
6766
test_done
6867
fi
68+
6969
if ! test_have_prereq PERL
7070
then
7171
skip_all='skipping git-cvsserver tests, perl not available'

t/t9402-git-cvsserver-refs.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ check_diff() {
6868

6969
#########
7070

71-
cvs >/dev/null 2>&1
72-
if test $? -ne 1
71+
if ! cvs version >/dev/null 2>&1
7372
then
7473
skip_all='skipping git-cvsserver tests, cvs not found'
7574
test_done
7675
fi
76+
7777
if ! test_have_prereq PERL
7878
then
7979
skip_all='skipping git-cvsserver tests, perl not available'

t/test-lib.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
143143
################################################################
144144
# It appears that people try to run tests without building...
145145
GIT_BINARY="${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X"
146-
"$GIT_BINARY" >/dev/null
147-
if test $? != 1
146+
147+
if ! "$GIT_BINARY" version >/dev/null
148148
then
149149
if test -n "$GIT_TEST_INSTALLED"
150150
then

0 commit comments

Comments
 (0)