Skip to content

Commit e05a988

Browse files
committed
tests: use the correct path separator with BusyBox
BusyBox-w32 is a true Win32 application, i.e. it does not come with a POSIX emulation layer. That also means that it does *not* use the Unix convention of separating the entries in the PATH variable using colons, but semicolons. However, there are also BusyBox ports to Windows which use a POSIX emulation layer such as Cygwin's or MSYS2's runtime, i.e. using colons as PATH separators. As a tell-tale, let's use the presence of semicolons in the PATH variable: on Unix, it is highly unlikely that it contains semicolons, and on Windows (without POSIX emulation), it is virtually guaranteed, as everybody should have both $SYSTEMROOT and $SYSTEMROOT/system32 in their PATH. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 0f23a77 commit e05a988

17 files changed

+54
-41
lines changed

t/interop/interop-lib.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
. ../../GIT-BUILD-OPTIONS
55
INTEROP_ROOT=$(pwd)
66
BUILD_ROOT=$INTEROP_ROOT/build
7+
case "$PATH" in
8+
*\;*) PATH_SEP=\; ;;
9+
*) PATH_SEP=: ;;
10+
esac
711

812
build_version () {
913
if test -z "$1"
@@ -57,7 +61,7 @@ wrap_git () {
5761
write_script "$1" <<-EOF
5862
GIT_EXEC_PATH="$2"
5963
export GIT_EXEC_PATH
60-
PATH="$2:\$PATH"
64+
PATH="$2$PATH_SEP\$PATH"
6165
export GIT_EXEC_PATH
6266
exec git "\$@"
6367
EOF
@@ -71,7 +75,7 @@ generate_wrappers () {
7175
echo >&2 fatal: test tried to run generic git: $*
7276
exit 1
7377
EOF
74-
PATH=$(pwd)/.bin:$PATH
78+
PATH=$(pwd)/.bin$PATH_SEP$PATH
7579
}
7680

7781
VERSION_A=${GIT_TEST_VERSION_A:-$VERSION_A}

t/lib-proto-disable.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ setup_ext_wrapper () {
214214
cd "$TRASH_DIRECTORY/remote" &&
215215
eval "$*"
216216
EOF
217-
PATH=$TRASH_DIRECTORY:$PATH &&
217+
PATH=$TRASH_DIRECTORY$PATH_SEP$PATH &&
218218
export TRASH_DIRECTORY
219219
'
220220
}

t/t0021-conversion.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
88
. ./test-lib.sh
99
. "$TEST_DIRECTORY"/lib-terminal.sh
1010

11-
PATH=$PWD:$PATH
11+
PATH=$PWD$PATH_SEP$PATH
1212
TEST_ROOT="$(pwd)"
1313

1414
write_script <<\EOF "$TEST_ROOT/rot13.sh"

t/t0060-path-utils.sh

+12-12
Original file line numberDiff line numberDiff line change
@@ -147,25 +147,25 @@ ancestor /foo /fo -1
147147
ancestor /foo /foo -1
148148
ancestor /foo /bar -1
149149
ancestor /foo /foo/bar -1
150-
ancestor /foo /foo:/bar -1
151-
ancestor /foo /:/foo:/bar 0
152-
ancestor /foo /foo:/:/bar 0
153-
ancestor /foo /:/bar:/foo 0
150+
ancestor /foo "/foo$PATH_SEP/bar" -1
151+
ancestor /foo "/$PATH_SEP/foo$PATH_SEP/bar" 0
152+
ancestor /foo "/foo$PATH_SEP/$PATH_SEP/bar" 0
153+
ancestor /foo "/$PATH_SEP/bar$PATH_SEP/foo" 0
154154
ancestor /foo/bar / 0
155155
ancestor /foo/bar /fo -1
156156
ancestor /foo/bar /foo 4
157157
ancestor /foo/bar /foo/ba -1
158-
ancestor /foo/bar /:/fo 0
159-
ancestor /foo/bar /foo:/foo/ba 4
158+
ancestor /foo/bar "/$PATH_SEP/fo" 0
159+
ancestor /foo/bar "/foo$PATH_SEP/foo/ba" 4
160160
ancestor /foo/bar /bar -1
161161
ancestor /foo/bar /fo -1
162-
ancestor /foo/bar /foo:/bar 4
163-
ancestor /foo/bar /:/foo:/bar 4
164-
ancestor /foo/bar /foo:/:/bar 4
165-
ancestor /foo/bar /:/bar:/fo 0
166-
ancestor /foo/bar /:/bar 0
162+
ancestor /foo/bar "/foo$PATH_SEP/bar" 4
163+
ancestor /foo/bar "/$PATH_SEP/foo$PATH_SEP/bar" 4
164+
ancestor /foo/bar "/foo$PATH_SEP/$PATH_SEP/bar" 4
165+
ancestor /foo/bar "/$PATH_SEP/bar$PATH_SEP/fo" 0
166+
ancestor /foo/bar "/$PATH_SEP/bar" 0
167167
ancestor /foo/bar /foo 4
168-
ancestor /foo/bar /foo:/bar 4
168+
ancestor /foo/bar "/foo$PATH_SEP/bar" 4
169169
ancestor /foo/bar /bar -1
170170

171171
# Windows-specific: DOS drives, network shares

t/t0061-run-command.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ test_expect_success 'run_command does not try to execute a directory' '
6969
cat bin2/greet
7070
EOF
7171
72-
PATH=$PWD/bin1:$PWD/bin2:$PATH \
72+
PATH=$PWD/bin1$PATH_SEP$PWD/bin2$PATH_SEP$PATH \
7373
test-tool run-command run-command greet >actual 2>err &&
7474
test_cmp bin2/greet actual &&
7575
test_must_be_empty err
@@ -86,7 +86,7 @@ test_expect_success POSIXPERM 'run_command passes over non-executable file' '
8686
cat bin2/greet
8787
EOF
8888
89-
PATH=$PWD/bin1:$PWD/bin2:$PATH \
89+
PATH=$PWD/bin1$PATH_SEP$PWD/bin2$PATH_SEP$PATH \
9090
test-tool run-command run-command greet >actual 2>err &&
9191
test_cmp bin2/greet actual &&
9292
test_must_be_empty err
@@ -106,7 +106,7 @@ test_expect_success POSIXPERM,SANITY 'unreadable directory in PATH' '
106106
git config alias.nitfol "!echo frotz" &&
107107
chmod a-rx local-command &&
108108
(
109-
PATH=./local-command:$PATH &&
109+
PATH=./local-command$PATH_SEP$PATH &&
110110
git nitfol >actual
111111
) &&
112112
echo frotz >expect &&

t/t0300-credentials.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ test_expect_success 'setup helper scripts' '
8080
printf "username=\\007latrix Lestrange\\n"
8181
EOF
8282
83-
PATH="$PWD:$PATH"
83+
PATH="$PWD$PATH_SEP$PATH"
8484
'
8585

8686
test_expect_success 'credential_fill invokes helper' '

t/t1504-ceiling-dirs.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ then
8484
GIT_CEILING_DIRECTORIES="$TRASH_ROOT/top/"
8585
test_fail subdir_ceil_at_top_slash
8686

87-
GIT_CEILING_DIRECTORIES=":$TRASH_ROOT/top"
87+
GIT_CEILING_DIRECTORIES="$PATH_SEP$TRASH_ROOT/top"
8888
test_prefix subdir_ceil_at_top_no_resolve "sub/dir/"
89-
GIT_CEILING_DIRECTORIES=":$TRASH_ROOT/top/"
89+
GIT_CEILING_DIRECTORIES="$PATH_SEP$TRASH_ROOT/top/"
9090
test_prefix subdir_ceil_at_top_slash_no_resolve "sub/dir/"
9191
fi
9292

@@ -116,13 +116,13 @@ GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
116116
test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
117117

118118

119-
GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
119+
GIT_CEILING_DIRECTORIES="/foo$PATH_SEP$TRASH_ROOT/sub"
120120
test_fail second_of_two
121121

122-
GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
122+
GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub$PATH_SEP/bar"
123123
test_fail first_of_two
124124

125-
GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
125+
GIT_CEILING_DIRECTORIES="/foo$PATH_SEP$TRASH_ROOT/sub$PATH_SEP/bar"
126126
test_fail second_of_three
127127

128128

t/t2300-cd-to-toplevel.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test_cd_to_toplevel () {
1616
test_expect_success $3 "$2" '
1717
(
1818
cd '"'$1'"' &&
19-
PATH="$EXEC_PATH:$PATH" &&
19+
PATH="$EXEC_PATH$PATH_SEP$PATH" &&
2020
. git-sh-setup &&
2121
cd_to_toplevel &&
2222
[ "$(pwd -P)" = "$TOPLEVEL" ]

t/t3418-rebase-continue.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ test_expect_success 'rebase --continue remembers merge strategy and options' '
8282
8383
rm -f actual &&
8484
(
85-
PATH=./test-bin:$PATH &&
85+
PATH=./test-bin$PATH_SEP$PATH &&
8686
test_must_fail git rebase -s funny -X"option=arg with space" \
8787
-Xop\"tion\\ -X"new${LF}line " main topic
8888
) &&
@@ -91,7 +91,7 @@ test_expect_success 'rebase --continue remembers merge strategy and options' '
9191
echo "Resolved" >F2 &&
9292
git add F2 &&
9393
(
94-
PATH=./test-bin:$PATH &&
94+
PATH=./test-bin$PATH_SEP$PATH &&
9595
git rebase --continue
9696
) &&
9797
test_cmp expect actual

t/t5615-alternate-env.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ test_expect_success 'access alternate via absolute path' '
3939
'
4040

4141
test_expect_success 'access multiple alternates' '
42-
check_obj "$PWD/one.git/objects:$PWD/two.git/objects" <<-EOF
42+
check_obj "$PWD/one.git/objects$PATH_SEP$PWD/two.git/objects" <<-EOF
4343
$one blob
4444
$two blob
4545
EOF
@@ -75,7 +75,7 @@ test_expect_success 'access alternate via relative path (subdir)' '
7575
quoted='"one.git\057objects"'
7676
unquoted='two.git/objects'
7777
test_expect_success 'mix of quoted and unquoted alternates' '
78-
check_obj "$quoted:$unquoted" <<-EOF
78+
check_obj "$quoted$PATH_SEP$unquoted" <<-EOF
7979
$one blob
8080
$two blob
8181
EOF

t/t5802-connect-helper.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ test_expect_success 'set up fake git-daemon' '
8686
"$TRASH_DIRECTORY/remote"
8787
EOF
8888
export TRASH_DIRECTORY &&
89-
PATH=$TRASH_DIRECTORY:$PATH
89+
PATH=$TRASH_DIRECTORY$PATH_SEP$PATH
9090
'
9191

9292
test_expect_success 'ext command can connect to git daemon (no vhost)' '

t/t7006-pager.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ test_expect_success !MINGW,TTY 'LESS and LV envvars set by git-sh-setup' '
5454
sane_unset LESS LV &&
5555
PAGER="env >pager-env.out; wc" &&
5656
export PAGER &&
57-
PATH="$(git --exec-path):$PATH" &&
57+
PATH="$(git --exec-path)$PATH_SEP$PATH" &&
5858
export PATH &&
5959
test_terminal sh -c ". git-sh-setup && git_pager"
6060
) &&
@@ -388,7 +388,7 @@ test_default_pager() {
388388
EOF
389389
chmod +x \$less &&
390390
(
391-
PATH=.:\$PATH &&
391+
PATH=.$PATH_SEP\$PATH &&
392392
export PATH &&
393393
$full_command
394394
) &&

t/t7606-merge-custom.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ test_expect_success 'set up custom strategy' '
2323
EOF
2424
2525
chmod +x git-merge-theirs &&
26-
PATH=.:$PATH &&
26+
PATH=.$PATH_SEP$PATH &&
2727
export PATH
2828
'
2929

t/t7811-grep-open.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ test_expect_success SIMPLEPAGER 'git grep -O' '
5252
EOF
5353
echo grep.h >expect.notless &&
5454
55-
PATH=.:$PATH git grep -O GREP_PATTERN >out &&
55+
PATH=.$PATH_SEP$PATH git grep -O GREP_PATTERN >out &&
5656
{
5757
test_cmp expect.less pager-args ||
5858
test_cmp expect.notless pager-args

t/t9003-help-autocorrect.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test_expect_success 'setup' '
1313
echo distimdistim was called
1414
EOF
1515
16-
PATH="$PATH:." &&
16+
PATH="$PATH$PATH_SEP." &&
1717
export PATH &&
1818
1919
git commit --allow-empty -m "a single log entry" &&

t/t9800-git-p4-basic.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ test_expect_success 'exit when p4 fails to produce marshaled output' '
286286
EOF
287287
chmod 755 badp4dir/p4 &&
288288
(
289-
PATH="$TRASH_DIRECTORY/badp4dir:$PATH" &&
289+
PATH="$TRASH_DIRECTORY/badp4dir$PATH_SEP$PATH" &&
290290
export PATH &&
291291
test_expect_code 1 git p4 clone --dest="$git" //depot >errs 2>&1
292292
) &&

t/test-lib.sh

+13-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515
# You should have received a copy of the GNU General Public License
1616
# along with this program. If not, see https://www.gnu.org/licenses/ .
1717

18+
# On Unix/Linux, the path separator is the colon, on other systems it
19+
# may be different, though. On Windows, for example, it is a semicolon.
20+
# If the PATH variable contains semicolons, it is pretty safe to assume
21+
# that the path separator is a semicolon.
22+
case "$PATH" in
23+
*\;*) PATH_SEP=\; ;;
24+
*) PATH_SEP=: ;;
25+
esac
26+
1827
# Test the binaries we have just built. The tests are kept in
1928
# t/ subdirectory and are run in 'trash directory' subdirectory.
2029
if test -z "$TEST_DIRECTORY"
@@ -1376,7 +1385,7 @@ then
13761385
done
13771386
done
13781387
IFS=$OLDIFS
1379-
PATH=$GIT_VALGRIND/bin:$PATH
1388+
PATH=$GIT_VALGRIND/bin$PATH_SEP$PATH
13801389
GIT_EXEC_PATH=$GIT_VALGRIND/bin
13811390
export GIT_VALGRIND
13821391
GIT_VALGRIND_MODE="$valgrind"
@@ -1388,7 +1397,7 @@ elif test -n "$GIT_TEST_INSTALLED"
13881397
then
13891398
GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) ||
13901399
error "Cannot run git from $GIT_TEST_INSTALLED."
1391-
PATH=$GIT_TEST_INSTALLED:$GIT_BUILD_DIR/t/helper:$PATH
1400+
PATH=$GIT_TEST_INSTALLED$PATH_SEP$GIT_BUILD_DIR/t/helper$PATH_SEP$PATH
13921401
GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
13931402
else # normal case, use ../bin-wrappers only unless $with_dashes:
13941403
if test -n "$no_bin_wrappers"
@@ -1404,12 +1413,12 @@ else # normal case, use ../bin-wrappers only unless $with_dashes:
14041413
fi
14051414
with_dashes=t
14061415
fi
1407-
PATH="$git_bin_dir:$PATH"
1416+
PATH="$git_bin_dir$PATH_SEP$PATH"
14081417
fi
14091418
GIT_EXEC_PATH=$GIT_BUILD_DIR
14101419
if test -n "$with_dashes"
14111420
then
1412-
PATH="$GIT_BUILD_DIR:$GIT_BUILD_DIR/t/helper:$PATH"
1421+
PATH="$GIT_BUILD_DIR$PATH_SEP$GIT_BUILD_DIR/t/helper$PATH_SEP$PATH"
14131422
fi
14141423
fi
14151424
GIT_TEMPLATE_DIR="$GIT_TEST_TEMPLATE_DIR"

0 commit comments

Comments
 (0)