|
3 | 3 | echo "${TEST_NAME} -- regression test for argv[0] -> sys.executable setting" |
4 | 4 |
|
5 | 5 | set -- ${PYTHON_IMPLS} |
| 6 | +GOOD=0 |
| 7 | +BAD=0 |
6 | 8 |
|
7 | | -while true; do |
8 | | - if [ ${#} -lt 1 ]; then |
9 | | - echo 'No working Python interpreter found (?!)' >&2 |
10 | | - do_exit 77 |
11 | | - fi |
| 9 | +while [ ${#} -gt 0 ]; do |
| 10 | + export EPYTHON="${1}" |
| 11 | + shift |
12 | 12 |
|
13 | 13 | # We have to have the proper Python version installed. |
14 | | - if ! "${1}" --version >&2; then |
15 | | - shift |
16 | | - else |
17 | | - break |
| 14 | + if ! "${EPYTHON}" --version >&2; then |
| 15 | + continue |
18 | 16 | fi |
19 | | -done |
20 | | - |
21 | | -export EPYTHON=${1} |
22 | 17 |
|
23 | | -echo "Python used: ${EPYTHON}" >&2 |
| 18 | + echo "Testing Python: ${EPYTHON}" >&2 |
| 19 | + PYTHON_PATH=$(command -v "${EPYTHON}") |
24 | 20 |
|
25 | | -PYTHON_PATH=$(command -v "${EPYTHON}") |
| 21 | + mkdir -p "${TEST_DIR}/${EPYTHON}" |
| 22 | + ln -f -s "${PYTHON_PATH}" "${TEST_DIR}/${EPYTHON}/python" |
26 | 23 |
|
27 | | -mkdir -p "${TEST_DIR}/${EPYTHON}" |
28 | | -ln -f -s "${PYTHON_PATH}" "${TEST_DIR}/${EPYTHON}/python" |
| 24 | + # replace with C wrapper |
| 25 | + ln -f -s python-exec2c "${TEST_DIR}/python" |
29 | 26 |
|
30 | | -# replace with C wrapper |
31 | | -ln -f -s python-exec2c "${TEST_DIR}/python" |
| 27 | + ORIG_EXE=$("${PYTHON_PATH}" -c 'import os.path, sys; print(os.path.realpath(sys.executable))') |
| 28 | + WRAP_EXE=$("${TEST_DIR}/python" -c 'import os.path, sys; print(os.path.realpath(sys.executable))') |
32 | 29 |
|
33 | | -ORIG_EXE=$("${PYTHON_PATH}" -c 'import os.path, sys; print(os.path.realpath(sys.executable))') |
34 | | -WRAP_EXE=$("${TEST_DIR}/python" -c 'import os.path, sys; print(os.path.realpath(sys.executable))') |
| 30 | + echo "Original realpath(sys.executable): ${ORIG_EXE}" |
| 31 | + echo "Wrapped realpath(sys.executable): ${WRAP_EXE}" |
35 | 32 |
|
36 | | -echo "Original realpath(sys.executable): ${ORIG_EXE}" |
37 | | -echo "Wrapped realpath(sys.executable): ${WRAP_EXE}" |
| 33 | + if [ "${ORIG_EXE}" = "${WRAP_EXE}" ]; then |
| 34 | + : $(( GOOD++ )) |
| 35 | + else |
| 36 | + : $(( BAD++ )) |
| 37 | + fi |
| 38 | +done |
38 | 39 |
|
39 | | -if [ "${ORIG_EXE}" = "${WRAP_EXE}" ]; then |
40 | | - do_exit 0 |
| 40 | +if [ ${BAD} -eq 0 ]; then |
| 41 | + if [ ${GOOD} -eq 0 ]; then |
| 42 | + echo 'No working Python interpreter found (?!)' >&2 |
| 43 | + do_exit 77 |
| 44 | + else |
| 45 | + do_exit 0 |
| 46 | + fi |
41 | 47 | else |
42 | 48 | do_exit 1 |
43 | 49 | fi |
0 commit comments