Git fork

t983*: use prereq to check for Python-specific git-p4(1) support

The tests in t9835 and t9836 verify that git-p4(1) works with both
Python 2 and 3, respectively. To determine whether we have those Python
versions in the first place we create a wrapper script that directly
executes the git-p4(1) script with `python2` or `python3` binaries. We
then condition the execution of tests on whether that wrapper script can
be executed successfully.

The logic that does all of this is not contained in a prerequisite block
though, so the output it generates causes us to break the TAP format.
Refactor the logic to use `test_lazy_prereq()` to fix this.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
a1199a23 84453709

+26 -22
+13 -11
t/t9835-git-p4-metadata-encoding-python2.sh
··· 12 12 ## SECTION REPEATED IN t9836 ## 13 13 ############################### 14 14 15 + EXTRA_PATH="$(pwd)/temp_python" 16 + mkdir "$EXTRA_PATH" 17 + PATH="$EXTRA_PATH:$PATH" 18 + export PATH 19 + 15 20 # These tests are specific to Python 2. Write a custom script that executes 16 21 # git-p4 directly with the Python 2 interpreter to ensure that we use that 17 22 # version even if Git was compiled with Python 3. 18 - python_target_binary=$(which python2) 19 - if test -n "$python_target_binary" 20 - then 21 - mkdir temp_python 22 - PATH="$(pwd)/temp_python:$PATH" 23 - export PATH 24 - 25 - write_script temp_python/git-p4-python2 <<-EOF 23 + test_lazy_prereq P4_PYTHON2 ' 24 + python_target_binary=$(which python2) && 25 + test -n "$python_target_binary" && 26 + write_script "$EXTRA_PATH"/git-p4-python2 <<-EOF && 26 27 exec "$python_target_binary" "$(git --exec-path)/git-p4" "\$@" 27 28 EOF 28 - fi 29 + ( git p4-python2 || true ) >err && 30 + test_grep "valid commands" err 31 + ' 29 32 30 - git p4-python2 >err 31 - if ! grep 'valid commands' err 33 + if ! test_have_prereq P4_PYTHON2 32 34 then 33 35 skip_all="skipping python2 git p4 tests; python2 not available" 34 36 test_done
+13 -11
t/t9836-git-p4-metadata-encoding-python3.sh
··· 12 12 ## SECTION REPEATED IN t9835 ## 13 13 ############################### 14 14 15 + EXTRA_PATH="$(pwd)/temp_python" 16 + mkdir "$EXTRA_PATH" 17 + PATH="$EXTRA_PATH:$PATH" 18 + export PATH 19 + 15 20 # These tests are specific to Python 3. Write a custom script that executes 16 21 # git-p4 directly with the Python 3 interpreter to ensure that we use that 17 22 # version even if Git was compiled with Python 2. 18 - python_target_binary=$(which python3) 19 - if test -n "$python_target_binary" 20 - then 21 - mkdir temp_python 22 - PATH="$(pwd)/temp_python:$PATH" 23 - export PATH 24 - 25 - write_script temp_python/git-p4-python3 <<-EOF 23 + test_lazy_prereq P4_PYTHON3 ' 24 + python_target_binary=$(which python3) && 25 + test -n "$python_target_binary" && 26 + write_script "$EXTRA_PATH"/git-p4-python3 <<-EOF && 26 27 exec "$python_target_binary" "$(git --exec-path)/git-p4" "\$@" 27 28 EOF 28 - fi 29 + ( git p4-python3 || true ) >err && 30 + test_grep "valid commands" err 31 + ' 29 32 30 - git p4-python3 >err 31 - if ! grep 'valid commands' err 33 + if ! test_have_prereq P4_PYTHON3 32 34 then 33 35 skip_all="skipping python3 git p4 tests; python3 not available" 34 36 test_done