aboutsummaryrefslogtreecommitdiffstats
path: root/t/t9835-git-p4-metadata-encoding-python2.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t9835-git-p4-metadata-encoding-python2.sh')
-rwxr-xr-xt/t9835-git-p4-metadata-encoding-python2.sh59
1 files changed, 30 insertions, 29 deletions
diff --git a/t/t9835-git-p4-metadata-encoding-python2.sh b/t/t9835-git-p4-metadata-encoding-python2.sh
index ad20ffdede..b969c7e0d5 100755
--- a/t/t9835-git-p4-metadata-encoding-python2.sh
+++ b/t/t9835-git-p4-metadata-encoding-python2.sh
@@ -6,32 +6,33 @@ This test checks that the import process handles inconsistent text
encoding in p4 metadata (author names, commit messages, etc) without
failing, and produces maximally sane output in git.'
-TEST_PASSES_SANITIZE_LEAK=true
. ./lib-git-p4.sh
-python_target_version='2'
-
###############################
## SECTION REPEATED IN t9836 ##
###############################
-# Please note: this test calls "git-p4.py" rather than "git-p4", because the
-# latter references a specific path so we can't easily force it to run under
-# the python version we need to.
-
-python_major_version=$(python -V 2>&1 | cut -c 8)
-python_target_binary=$(which python$python_target_version)
-if ! test "$python_major_version" = "$python_target_version" && test "$python_target_binary"
-then
- mkdir temp_python
- PATH="$(pwd)/temp_python:$PATH" && export PATH
- ln -s $python_target_binary temp_python/python
-fi
+EXTRA_PATH="$(pwd)/temp_python"
+mkdir "$EXTRA_PATH"
+PATH="$EXTRA_PATH:$PATH"
+export PATH
+
+# These tests are specific to Python 2. Write a custom script that executes
+# git-p4 directly with the Python 2 interpreter to ensure that we use that
+# version even if Git was compiled with Python 3.
+test_lazy_prereq P4_PYTHON2 '
+ python_target_binary=$(which python2) &&
+ test -n "$python_target_binary" &&
+ write_script "$EXTRA_PATH"/git-p4-python2 <<-EOF &&
+ exec "$python_target_binary" "$(git --exec-path)/git-p4" "\$@"
+ EOF
+ ( git p4-python2 || true ) >err &&
+ test_grep "valid commands" err
+'
-python_major_version=$(python -V 2>&1 | cut -c 8)
-if ! test "$python_major_version" = "$python_target_version"
+if ! test_have_prereq P4_PYTHON2
then
- skip_all="skipping python$python_target_version-specific git p4 tests; python$python_target_version not available"
+ skip_all="skipping python2 git p4 tests; python2 not available"
test_done
fi
@@ -82,14 +83,14 @@ test_expect_success 'init depot' '
test_expect_success 'clone non-utf8 repo with strict encoding' '
test_when_finished cleanup_git &&
test_when_finished remove_user_cache &&
- test_must_fail git -c git-p4.metadataDecodingStrategy=strict p4.py clone --dest="$git" //depot@all 2>err &&
+ test_must_fail git -c git-p4.metadataDecodingStrategy=strict p4-python2 clone --dest="$git" //depot@all 2>err &&
grep "Decoding perforce metadata failed!" err
'
test_expect_success 'check utf-8 contents with passthrough strategy' '
test_when_finished cleanup_git &&
test_when_finished remove_user_cache &&
- git -c git-p4.metadataDecodingStrategy=passthrough p4.py clone --dest="$git" //depot@all &&
+ git -c git-p4.metadataDecodingStrategy=passthrough p4-python2 clone --dest="$git" //depot@all &&
(
cd "$git" &&
git log >actual &&
@@ -101,7 +102,7 @@ test_expect_success 'check utf-8 contents with passthrough strategy' '
test_expect_success 'check latin-1 contents corrupted in git with passthrough strategy' '
test_when_finished cleanup_git &&
test_when_finished remove_user_cache &&
- git -c git-p4.metadataDecodingStrategy=passthrough p4.py clone --dest="$git" //depot@all &&
+ git -c git-p4.metadataDecodingStrategy=passthrough p4-python2 clone --dest="$git" //depot@all &&
(
cd "$git" &&
git log >actual &&
@@ -115,7 +116,7 @@ test_expect_success 'check latin-1 contents corrupted in git with passthrough st
test_expect_success 'check utf-8 contents with fallback strategy' '
test_when_finished cleanup_git &&
test_when_finished remove_user_cache &&
- git -c git-p4.metadataDecodingStrategy=fallback p4.py clone --dest="$git" //depot@all &&
+ git -c git-p4.metadataDecodingStrategy=fallback p4-python2 clone --dest="$git" //depot@all &&
(
cd "$git" &&
git log >actual &&
@@ -127,7 +128,7 @@ test_expect_success 'check utf-8 contents with fallback strategy' '
test_expect_success 'check latin-1 contents with fallback strategy' '
test_when_finished cleanup_git &&
test_when_finished remove_user_cache &&
- git -c git-p4.metadataDecodingStrategy=fallback p4.py clone --dest="$git" //depot@all &&
+ git -c git-p4.metadataDecodingStrategy=fallback p4-python2 clone --dest="$git" //depot@all &&
(
cd "$git" &&
git log >actual &&
@@ -139,7 +140,7 @@ test_expect_success 'check latin-1 contents with fallback strategy' '
test_expect_success 'check cp-1252 contents with fallback strategy' '
test_when_finished cleanup_git &&
test_when_finished remove_user_cache &&
- git -c git-p4.metadataDecodingStrategy=fallback p4.py clone --dest="$git" //depot@all &&
+ git -c git-p4.metadataDecodingStrategy=fallback p4-python2 clone --dest="$git" //depot@all &&
(
cd "$git" &&
git log >actual &&
@@ -151,7 +152,7 @@ test_expect_success 'check cp-1252 contents with fallback strategy' '
test_expect_success 'check cp850 contents parsed with correct fallback' '
test_when_finished cleanup_git &&
test_when_finished remove_user_cache &&
- git -c git-p4.metadataDecodingStrategy=fallback -c git-p4.metadataFallbackEncoding=cp850 p4.py clone --dest="$git" //depot@all &&
+ git -c git-p4.metadataDecodingStrategy=fallback -c git-p4.metadataFallbackEncoding=cp850 p4-python2 clone --dest="$git" //depot@all &&
(
cd "$git" &&
git log >actual &&
@@ -163,7 +164,7 @@ test_expect_success 'check cp850 contents parsed with correct fallback' '
test_expect_success 'check cp850-only contents escaped when cp1252 is fallback' '
test_when_finished cleanup_git &&
test_when_finished remove_user_cache &&
- git -c git-p4.metadataDecodingStrategy=fallback p4.py clone --dest="$git" //depot@all &&
+ git -c git-p4.metadataDecodingStrategy=fallback p4-python2 clone --dest="$git" //depot@all &&
(
cd "$git" &&
git log >actual &&
@@ -175,7 +176,7 @@ test_expect_success 'check cp850-only contents escaped when cp1252 is fallback'
test_expect_success 'check cp-1252 contents on later sync after clone with fallback strategy' '
test_when_finished cleanup_git &&
test_when_finished remove_user_cache &&
- git -c git-p4.metadataDecodingStrategy=fallback p4.py clone --dest="$git" //depot@all &&
+ git -c git-p4.metadataDecodingStrategy=fallback p4-python2 clone --dest="$git" //depot@all &&
(
cd "$cli" &&
P4USER=cp1252_author &&
@@ -187,7 +188,7 @@ test_expect_success 'check cp-1252 contents on later sync after clone with fallb
(
cd "$git" &&
- git p4.py sync --branch=master &&
+ git p4-python2 sync --branch=master &&
git log p4/master >actual &&
grep "sœme more cp-1252 tæxt" actual &&
@@ -202,7 +203,7 @@ test_expect_success 'check cp-1252 contents on later sync after clone with fallb
test_expect_success 'passthrough (latin-1 contents corrupted in git) is the default with python2' '
test_when_finished cleanup_git &&
test_when_finished remove_user_cache &&
- git -c git-p4.metadataDecodingStrategy=passthrough p4.py clone --dest="$git" //depot@all &&
+ git -c git-p4.metadataDecodingStrategy=passthrough p4-python2 clone --dest="$git" //depot@all &&
(
cd "$git" &&
git log >actual &&