#!/bin/sh

echo "${TEST_NAME} -- test whether python-exec.conf is respected"

set -- ${PYTHON_IMPLS}

unset ESELECT
while true; do
	if [ ${#} -lt 2 ]; then
		# we can't test a preference without at least two impls ;)
		echo 'Best Python eselected, unable to perform test.' >&2
		do_exit 77
	fi

	# Repeat until we find the eselected python.
	if [ -z "${ESELECT}" ]; then
		# Find one of the preferred impls.
		if is_preferred "${1}"; then
			ESELECT="${1}"
		fi
		shift
	else
		# The other impl shouldn't be disabled to get conclusive result.
		if ! is_disabled "${1}"; then
			BETTER=${1}
			break
		fi
		shift
	fi
done

echo "other impl: ${BETTER}" >&2

unset EPYTHON

write_impl "${ESELECT}" "#!/usr/bin/env true"
write_impl "${BETTER}"  "#!/usr/bin/env false"

do_test "${TEST_TMP}"
