mirror of
https://github.com/mnauw/git-remote-hg.git
synced 2025-11-05 02:55:40 +01:00
Run Python scripts under the chosen version
The Python scripts have unversioned Python shebangs so tests will fail if the chosen Python version is not unversioned Python. Copy the scripts to tmp dirs and change the shebang to the chosen Python. Also prevent sharness from adding the unversioned Python scripts to PATH.
This commit is contained in:
committed by
Mark Nauwelaerts
parent
3b11156e69
commit
f5c38f3a59
@@ -18,7 +18,14 @@ if [ -z "$SHARNESS" ] || [ ! -f "$SHARNESS" ] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Prevent sharness from adding the source directory to PATH
|
||||
# since the scripts use unversioned python for their shebang
|
||||
# but tests should run under the python with mercurial support
|
||||
# so create an empty directory and strip it from PATH afterwards
|
||||
SHARNESS_BUILD_DIRECTORY="$(mktemp -d)"
|
||||
. "$SHARNESS"
|
||||
export PATH="${PATH#*:}"
|
||||
rmdir "$SHARNESS_BUILD_DIRECTORY"
|
||||
|
||||
if [ -n "$PYTHON" ] && "$PYTHON" -c 'import mercurial' 2> /dev/null ; then
|
||||
: Use chosen Python version
|
||||
@@ -29,7 +36,20 @@ elif python2 -c 'import mercurial' 2> /dev/null ; then
|
||||
elif python -c 'import mercurial' 2> /dev/null ; then
|
||||
PYTHON=python
|
||||
fi
|
||||
test -n "$PYTHON" && test_set_prereq PYTHON
|
||||
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
|
||||
|
||||
GIT_AUTHOR_EMAIL=author@example.com
|
||||
GIT_AUTHOR_NAME='A U Thor'
|
||||
|
||||
Reference in New Issue
Block a user