Skip to content

Commit 8337fc0

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 <[email protected]>
1 parent 308658b commit 8337fc0

18 files changed

+57
-44
lines changed

t/interop/interop-lib.sh

Lines changed: 6 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ test_description='blob conversion via gitattributes'
55
. ./test-lib.sh
66

77
TEST_ROOT="$PWD"
8-
PATH=$TEST_ROOT:$PATH
8+
PATH=$TEST_ROOT$PATH_SEP$PATH
99

1010
write_script <<\EOF "$TEST_ROOT/rot13.sh"
1111
tr \

t/t0060-path-utils.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,25 +135,25 @@ ancestor /foo /fo -1
135135
ancestor /foo /foo -1
136136
ancestor /foo /bar -1
137137
ancestor /foo /foo/bar -1
138-
ancestor /foo /foo:/bar -1
139-
ancestor /foo /:/foo:/bar 0
140-
ancestor /foo /foo:/:/bar 0
141-
ancestor /foo /:/bar:/foo 0
138+
ancestor /foo "/foo$PATH_SEP/bar" -1
139+
ancestor /foo "/$PATH_SEP/foo$PATH_SEP/bar" 0
140+
ancestor /foo "/foo$PATH_SEP/$PATH_SEP/bar" 0
141+
ancestor /foo "/$PATH_SEP/bar$PATH_SEP/foo" 0
142142
ancestor /foo/bar / 0
143143
ancestor /foo/bar /fo -1
144144
ancestor /foo/bar /foo 4
145145
ancestor /foo/bar /foo/ba -1
146-
ancestor /foo/bar /:/fo 0
147-
ancestor /foo/bar /foo:/foo/ba 4
146+
ancestor /foo/bar "/$PATH_SEP/fo" 0
147+
ancestor /foo/bar "/foo$PATH_SEP/foo/ba" 4
148148
ancestor /foo/bar /bar -1
149149
ancestor /foo/bar /fo -1
150-
ancestor /foo/bar /foo:/bar 4
151-
ancestor /foo/bar /:/foo:/bar 4
152-
ancestor /foo/bar /foo:/:/bar 4
153-
ancestor /foo/bar /:/bar:/fo 0
154-
ancestor /foo/bar /:/bar 0
150+
ancestor /foo/bar "/foo$PATH_SEP/bar" 4
151+
ancestor /foo/bar "/$PATH_SEP/foo$PATH_SEP/bar" 4
152+
ancestor /foo/bar "/foo$PATH_SEP/$PATH_SEP/bar" 4
153+
ancestor /foo/bar "/$PATH_SEP/bar$PATH_SEP/fo" 0
154+
ancestor /foo/bar "/$PATH_SEP/bar" 0
155155
ancestor /foo/bar /foo 4
156-
ancestor /foo/bar /foo:/bar 4
156+
ancestor /foo/bar "/foo$PATH_SEP/bar" 4
157157
ancestor /foo/bar /bar -1
158158

159159
test_expect_success 'strip_path_suffix' '

t/t0061-run-command.sh

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ test_expect_success 'setup helper scripts' '
3535
test -z "$pass" || echo password=$pass
3636
EOF
3737
38-
PATH="$PWD:$PATH"
38+
PATH="$PWD$PATH_SEP$PATH"
3939
'
4040

4141
test_expect_success 'credential_fill invokes helper' '

t/t1504-ceiling-dirs.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ then
7979
GIT_CEILING_DIRECTORIES="$TRASH_ROOT/top/"
8080
test_fail subdir_ceil_at_top_slash
8181

82-
GIT_CEILING_DIRECTORIES=":$TRASH_ROOT/top"
82+
GIT_CEILING_DIRECTORIES="$PATH_SEP$TRASH_ROOT/top"
8383
test_prefix subdir_ceil_at_top_no_resolve "sub/dir/"
84-
GIT_CEILING_DIRECTORIES=":$TRASH_ROOT/top/"
84+
GIT_CEILING_DIRECTORIES="$PATH_SEP$TRASH_ROOT/top/"
8585
test_prefix subdir_ceil_at_top_slash_no_resolve "sub/dir/"
8686
fi
8787

@@ -111,13 +111,13 @@ GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
111111
test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
112112

113113

114-
GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
114+
GIT_CEILING_DIRECTORIES="/foo$PATH_SEP$TRASH_ROOT/sub"
115115
test_fail second_of_two
116116

117-
GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
117+
GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub$PATH_SEP/bar"
118118
test_fail first_of_two
119119

120-
GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
120+
GIT_CEILING_DIRECTORIES="/foo$PATH_SEP$TRASH_ROOT/sub$PATH_SEP/bar"
121121
test_fail second_of_three
122122

123123

t/t2300-cd-to-toplevel.sh

Lines changed: 1 addition & 1 deletion
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/t3402-rebase-merge.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ test_expect_success 'rebase -s funny -Xopt' '
143143
git checkout -b test-funny master^ &&
144144
test_commit funny &&
145145
(
146-
PATH=./test-bin:$PATH &&
146+
PATH=./test-bin$PATH_SEP$PATH &&
147147
git rebase -s funny -Xopt master
148148
) &&
149149
test -f funny.was.run

t/t3418-rebase-continue.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ test_expect_success 'rebase --continue remembers merge strategy and options' '
6060
EOF
6161
chmod +x test-bin/git-merge-funny &&
6262
(
63-
PATH=./test-bin:$PATH &&
63+
PATH=./test-bin$PATH_SEP$PATH &&
6464
test_must_fail git rebase -s funny -Xopt master topic
6565
) &&
6666
test -f funny.was.run &&
6767
rm funny.was.run &&
6868
echo "Resolved" >F2 &&
6969
git add F2 &&
7070
(
71-
PATH=./test-bin:$PATH &&
71+
PATH=./test-bin$PATH_SEP$PATH &&
7272
git rebase --continue
7373
) &&
7474
test -f funny.was.run
@@ -92,15 +92,15 @@ test_expect_success 'rebase -i --continue handles merge strategy and options' '
9292
EOF
9393
chmod +x test-bin/git-merge-funny &&
9494
(
95-
PATH=./test-bin:$PATH &&
95+
PATH=./test-bin$PATH_SEP$PATH &&
9696
test_must_fail git rebase -i -s funny -Xopt -Xfoo master topic
9797
) &&
9898
test -f funny.was.run &&
9999
rm funny.was.run &&
100100
echo "Resolved" >F2 &&
101101
git add F2 &&
102102
(
103-
PATH=./test-bin:$PATH &&
103+
PATH=./test-bin$PATH_SEP$PATH &&
104104
git rebase --continue
105105
) &&
106106
test -f funny.was.run

0 commit comments

Comments
 (0)