From 88b2756e4383032f2d31746245c56bd69a3e861b Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Sat, 23 Aug 2025 20:25:25 +0200 Subject: [PATCH] t: post-merge adjust of test-lib.sh --- t/test-lib.sh | 58 +++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index 8ccefae..4cdf6e6 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -29,35 +29,6 @@ SHARNESS_BUILD_DIRECTORY="$(mktemp -d)" export PATH="${PATH#*:}" rmdir "$SHARNESS_BUILD_DIRECTORY" -if [ -z "$TEST_INSTALLED_SCRIPTS" ] ; then - if [ -n "$PYTHON" ] && "$PYTHON" -c 'import mercurial' 2> /dev/null ; then - : Use chosen Python version - elif python3 -c 'import mercurial' 2> /dev/null ; then - PYTHON=python3 - elif python2 -c 'import mercurial' 2> /dev/null ; then - PYTHON=python2 - elif python -c 'import mercurial' 2> /dev/null ; then - PYTHON=python - fi - if [ -n "$PYTHON" ] ; then - test_set_prereq PYTHON - - # Change shebang on a copy of scripts to chosen Python version - TEST_BIN="$SHARNESS_TRASH_DIRECTORY/bin" - mkdir -p "$TEST_BIN" - for s in git-remote-hg git-hg-helper ; do - printf "%s\n" "#!/usr/bin/env $PYTHON" > "$TEST_BIN/$s" - tail -n +2 "$SHARNESS_TEST_DIRECTORY/../$s" >> "$TEST_BIN/$s" - chmod u+x "$TEST_BIN/$s" - done - export PATH="$TEST_BIN${PATH:+:$PATH}" - unset TEST_BIN - fi -else - # The build/install process ensures Python is available - test_set_prereq PYTHON -fi - GIT_AUTHOR_EMAIL=author@example.com GIT_AUTHOR_NAME='A U Thor' GIT_COMMITTER_EMAIL=committer@example.com @@ -134,3 +105,32 @@ test_have_prereq() { return 1 } + +if [ -z "$TEST_INSTALLED_SCRIPTS" ] ; then + if [ -n "$PYTHON" ] && "$PYTHON" -c 'import mercurial' 2> /dev/null ; then + : Use chosen Python version + elif python3 -c 'import mercurial' 2> /dev/null ; then + PYTHON=python3 + elif python2 -c 'import mercurial' 2> /dev/null ; then + PYTHON=python2 + elif python -c 'import mercurial' 2> /dev/null ; then + PYTHON=python + fi + if [ -n "$PYTHON" ] ; then + test_set_prereq PYTHON + + # Change shebang on a copy of scripts to chosen Python version + TEST_BIN="$SHARNESS_TRASH_DIRECTORY/bin" + mkdir -p "$TEST_BIN" + for s in git-remote-hg git-hg-helper ; do + printf "%s\n" "#!/usr/bin/env $PYTHON" > "$TEST_BIN/$s" + tail -n +2 "$SHARNESS_TEST_DIRECTORY/../$s" >> "$TEST_BIN/$s" + chmod u+x "$TEST_BIN/$s" + done + export PATH="$TEST_BIN${PATH:+:$PATH}" + unset TEST_BIN + fi +else + # The build/install process ensures Python is available + test_set_prereq PYTHON +fi