@@ -8,29 +8,29 @@ failing, and produces maximally sane output in git.'
88
99. ./lib-git-p4.sh
1010
11- python_target_version=' 2'
12-
1311# ##############################
1412# # SECTION REPEATED IN t9836 ##
1513# ##############################
1614
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 "
2420then
2521 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
2828fi
2929
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
3232then
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"
3434 test_done
3535fi
3636
@@ -81,14 +81,14 @@ test_expect_success 'init depot' '
8181test_expect_success ' clone non-utf8 repo with strict encoding' '
8282 test_when_finished cleanup_git &&
8383 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 &&
8585 grep "Decoding perforce metadata failed!" err
8686'
8787
8888test_expect_success ' check utf-8 contents with passthrough strategy' '
8989 test_when_finished cleanup_git &&
9090 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 &&
9292 (
9393 cd "$git" &&
9494 git log >actual &&
@@ -100,7 +100,7 @@ test_expect_success 'check utf-8 contents with passthrough strategy' '
100100test_expect_success ' check latin-1 contents corrupted in git with passthrough strategy' '
101101 test_when_finished cleanup_git &&
102102 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 &&
104104 (
105105 cd "$git" &&
106106 git log >actual &&
@@ -114,7 +114,7 @@ test_expect_success 'check latin-1 contents corrupted in git with passthrough st
114114test_expect_success ' check utf-8 contents with fallback strategy' '
115115 test_when_finished cleanup_git &&
116116 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 &&
118118 (
119119 cd "$git" &&
120120 git log >actual &&
@@ -126,7 +126,7 @@ test_expect_success 'check utf-8 contents with fallback strategy' '
126126test_expect_success ' check latin-1 contents with fallback strategy' '
127127 test_when_finished cleanup_git &&
128128 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 &&
130130 (
131131 cd "$git" &&
132132 git log >actual &&
@@ -138,7 +138,7 @@ test_expect_success 'check latin-1 contents with fallback strategy' '
138138test_expect_success ' check cp-1252 contents with fallback strategy' '
139139 test_when_finished cleanup_git &&
140140 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 &&
142142 (
143143 cd "$git" &&
144144 git log >actual &&
@@ -150,7 +150,7 @@ test_expect_success 'check cp-1252 contents with fallback strategy' '
150150test_expect_success ' check cp850 contents parsed with correct fallback' '
151151 test_when_finished cleanup_git &&
152152 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 &&
154154 (
155155 cd "$git" &&
156156 git log >actual &&
@@ -162,7 +162,7 @@ test_expect_success 'check cp850 contents parsed with correct fallback' '
162162test_expect_success ' check cp850-only contents escaped when cp1252 is fallback' '
163163 test_when_finished cleanup_git &&
164164 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 &&
166166 (
167167 cd "$git" &&
168168 git log >actual &&
@@ -174,7 +174,7 @@ test_expect_success 'check cp850-only contents escaped when cp1252 is fallback'
174174test_expect_success ' check cp-1252 contents on later sync after clone with fallback strategy' '
175175 test_when_finished cleanup_git &&
176176 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 &&
178178 (
179179 cd "$cli" &&
180180 P4USER=cp1252_author &&
@@ -186,7 +186,7 @@ test_expect_success 'check cp-1252 contents on later sync after clone with fallb
186186 (
187187 cd "$git" &&
188188
189- git p4.py sync --branch=master &&
189+ git p4-python2 sync --branch=master &&
190190
191191 git log p4/master >actual &&
192192 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
201201test_expect_success ' passthrough (latin-1 contents corrupted in git) is the default with python2' '
202202 test_when_finished cleanup_git &&
203203 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 &&
205205 (
206206 cd "$git" &&
207207 git log >actual &&
0 commit comments