@@ -8,29 +8,29 @@ failing, and produces maximally sane output in git.'
8
8
9
9
. ./lib-git-p4.sh
10
10
11
- python_target_version=' 2'
12
-
13
11
# ##############################
14
12
# # SECTION REPEATED IN t9836 ##
15
13
# ##############################
16
14
17
- # Please note: this test calls "git-p4.py" rather than "git-p4", because the
18
- # latter references a specific path so we can't easily force it to run under
19
- # the python version we need to.
20
-
21
- python_major_version=$( python -V 2>&1 | cut -c 8)
22
- python_target_binary=$( which python$python_target_version )
23
- if ! test " $python_major_version " = " $python_target_version " && test " $python_target_binary "
15
+ # These tests are specific to Python 2. Write a custom script that executes
16
+ # git-p4 directly with the Python 2 interpreter to ensure that we use that
17
+ # version even if Git was compiled with Python 3.
18
+ python_target_binary=$( which python2)
19
+ if test -n " $python_target_binary "
24
20
then
25
21
mkdir temp_python
26
- PATH=" $( pwd) /temp_python:$PATH " && export PATH
27
- ln -s $python_target_binary temp_python/python
22
+ PATH=" $( pwd) /temp_python:$PATH "
23
+ export PATH
24
+
25
+ write_script temp_python/git-p4-python2 << -EOF
26
+ exec "$python_target_binary " "$( git --exec-path) /git-p4" "\$ @"
27
+ EOF
28
28
fi
29
29
30
- python_major_version= $( python -V 2>&1 | cut -c 8 )
31
- if ! test " $python_major_version " = " $python_target_version "
30
+ git p4-python2 > err
31
+ if ! grep ' valid commands ' err
32
32
then
33
- skip_all=" skipping python $python_target_version -specific git p4 tests; python $python_target_version not available"
33
+ skip_all=" skipping python2 git p4 tests; python2 not available"
34
34
test_done
35
35
fi
36
36
@@ -81,14 +81,14 @@ test_expect_success 'init depot' '
81
81
test_expect_success ' clone non-utf8 repo with strict encoding' '
82
82
test_when_finished cleanup_git &&
83
83
test_when_finished remove_user_cache &&
84
- test_must_fail git -c git-p4.metadataDecodingStrategy=strict p4.py clone --dest="$git" //depot@all 2>err &&
84
+ test_must_fail git -c git-p4.metadataDecodingStrategy=strict p4-python2 clone --dest="$git" //depot@all 2>err &&
85
85
grep "Decoding perforce metadata failed!" err
86
86
'
87
87
88
88
test_expect_success ' check utf-8 contents with passthrough strategy' '
89
89
test_when_finished cleanup_git &&
90
90
test_when_finished remove_user_cache &&
91
- git -c git-p4.metadataDecodingStrategy=passthrough p4.py clone --dest="$git" //depot@all &&
91
+ git -c git-p4.metadataDecodingStrategy=passthrough p4-python2 clone --dest="$git" //depot@all &&
92
92
(
93
93
cd "$git" &&
94
94
git log >actual &&
@@ -100,7 +100,7 @@ test_expect_success 'check utf-8 contents with passthrough strategy' '
100
100
test_expect_success ' check latin-1 contents corrupted in git with passthrough strategy' '
101
101
test_when_finished cleanup_git &&
102
102
test_when_finished remove_user_cache &&
103
- git -c git-p4.metadataDecodingStrategy=passthrough p4.py clone --dest="$git" //depot@all &&
103
+ git -c git-p4.metadataDecodingStrategy=passthrough p4-python2 clone --dest="$git" //depot@all &&
104
104
(
105
105
cd "$git" &&
106
106
git log >actual &&
@@ -114,7 +114,7 @@ test_expect_success 'check latin-1 contents corrupted in git with passthrough st
114
114
test_expect_success ' check utf-8 contents with fallback strategy' '
115
115
test_when_finished cleanup_git &&
116
116
test_when_finished remove_user_cache &&
117
- git -c git-p4.metadataDecodingStrategy=fallback p4.py clone --dest="$git" //depot@all &&
117
+ git -c git-p4.metadataDecodingStrategy=fallback p4-python2 clone --dest="$git" //depot@all &&
118
118
(
119
119
cd "$git" &&
120
120
git log >actual &&
@@ -126,7 +126,7 @@ test_expect_success 'check utf-8 contents with fallback strategy' '
126
126
test_expect_success ' check latin-1 contents with fallback strategy' '
127
127
test_when_finished cleanup_git &&
128
128
test_when_finished remove_user_cache &&
129
- git -c git-p4.metadataDecodingStrategy=fallback p4.py clone --dest="$git" //depot@all &&
129
+ git -c git-p4.metadataDecodingStrategy=fallback p4-python2 clone --dest="$git" //depot@all &&
130
130
(
131
131
cd "$git" &&
132
132
git log >actual &&
@@ -138,7 +138,7 @@ test_expect_success 'check latin-1 contents with fallback strategy' '
138
138
test_expect_success ' check cp-1252 contents with fallback strategy' '
139
139
test_when_finished cleanup_git &&
140
140
test_when_finished remove_user_cache &&
141
- git -c git-p4.metadataDecodingStrategy=fallback p4.py clone --dest="$git" //depot@all &&
141
+ git -c git-p4.metadataDecodingStrategy=fallback p4-python2 clone --dest="$git" //depot@all &&
142
142
(
143
143
cd "$git" &&
144
144
git log >actual &&
@@ -150,7 +150,7 @@ test_expect_success 'check cp-1252 contents with fallback strategy' '
150
150
test_expect_success ' check cp850 contents parsed with correct fallback' '
151
151
test_when_finished cleanup_git &&
152
152
test_when_finished remove_user_cache &&
153
- git -c git-p4.metadataDecodingStrategy=fallback -c git-p4.metadataFallbackEncoding=cp850 p4.py clone --dest="$git" //depot@all &&
153
+ git -c git-p4.metadataDecodingStrategy=fallback -c git-p4.metadataFallbackEncoding=cp850 p4-python2 clone --dest="$git" //depot@all &&
154
154
(
155
155
cd "$git" &&
156
156
git log >actual &&
@@ -162,7 +162,7 @@ test_expect_success 'check cp850 contents parsed with correct fallback' '
162
162
test_expect_success ' check cp850-only contents escaped when cp1252 is fallback' '
163
163
test_when_finished cleanup_git &&
164
164
test_when_finished remove_user_cache &&
165
- git -c git-p4.metadataDecodingStrategy=fallback p4.py clone --dest="$git" //depot@all &&
165
+ git -c git-p4.metadataDecodingStrategy=fallback p4-python2 clone --dest="$git" //depot@all &&
166
166
(
167
167
cd "$git" &&
168
168
git log >actual &&
@@ -174,7 +174,7 @@ test_expect_success 'check cp850-only contents escaped when cp1252 is fallback'
174
174
test_expect_success ' check cp-1252 contents on later sync after clone with fallback strategy' '
175
175
test_when_finished cleanup_git &&
176
176
test_when_finished remove_user_cache &&
177
- git -c git-p4.metadataDecodingStrategy=fallback p4.py clone --dest="$git" //depot@all &&
177
+ git -c git-p4.metadataDecodingStrategy=fallback p4-python2 clone --dest="$git" //depot@all &&
178
178
(
179
179
cd "$cli" &&
180
180
P4USER=cp1252_author &&
@@ -186,7 +186,7 @@ test_expect_success 'check cp-1252 contents on later sync after clone with fallb
186
186
(
187
187
cd "$git" &&
188
188
189
- git p4.py sync --branch=master &&
189
+ git p4-python2 sync --branch=master &&
190
190
191
191
git log p4/master >actual &&
192
192
grep "sœme more cp-1252 tæxt" actual &&
@@ -201,7 +201,7 @@ test_expect_success 'check cp-1252 contents on later sync after clone with fallb
201
201
test_expect_success ' passthrough (latin-1 contents corrupted in git) is the default with python2' '
202
202
test_when_finished cleanup_git &&
203
203
test_when_finished remove_user_cache &&
204
- git -c git-p4.metadataDecodingStrategy=passthrough p4.py clone --dest="$git" //depot@all &&
204
+ git -c git-p4.metadataDecodingStrategy=passthrough p4-python2 clone --dest="$git" //depot@all &&
205
205
(
206
206
cd "$git" &&
207
207
git log >actual &&
0 commit comments