Commits

Michał Górny committed 7b04e91

Tests: ensure that EPYTHON != eselected Python.

Otherwise, the test would succeed even if EPYTHON wasn't respected.

  • Participants
  • Parent commits b3c26a5

Comments (0)

Files changed (2)

File tests/epython-test

 
 set -- ${PYTHON_IMPLS}
 
-if [ ${#} -le 2 ]; then
-	# we can't test a preference without at least two impls ;)
-	echo 'Not enough implementations to perform test.' >&2
-	do_exit 77
-fi
+SEL_PY2=$(get_eselected --python2)
+SEL_PY3=$(get_eselected --python3)
+
+while true; do
+	if [ ${#} -lt 2 ]; then
+		# we can't test a preference without at least two impls ;)
+		echo 'Not enough implementations to perform test.' >&2
+		do_exit 77
+	fi
+
+	# EPYTHON can't be one of eselected pythons, otherwise the result
+	# would be inconclusive.
+	if [ "${1}" = "${SEL_PY2}" -o "${1}" = "${SEL_PY3}" ]; then
+		shift
+	else
+		break
+	fi
+done
 
 export EPYTHON=${1}
 BETTER=${2}

File tests/runner.sh

 	do_exit ${ret}
 }
 
+get_eselected() {
+	set +e
+
+	set -- eselect python show "${@}"
+	ret=$("${@}")
+	echo "${ret}"
+
+	[ -n "${ret}" ] || ret='(none)'
+	echo "${*} -> ${ret}" >&2
+
+	set -e
+}
+
 # catch all failures
 trap 'exit 99' EXIT
 set -e