Commits

Michał Górny committed 4c11221

Tests: check whether eselect is respected.

  • Participants
  • Parent commits 7b04e91

Comments (0)

Files changed (3)

 
 LOG_COMPILER = sh $(srcdir)/tests/runner.sh "$(PYTHON_IMPLS)"
 
-TESTS = tests/epython-test
+TESTS = tests/epython-test tests/eselect-test
 
 EXTRA_DIST += NEWS
 NEWS: configure.ac Makefile.am

File tests/epython-test

 #!/bin/sh
-# Test whether EPYTHON is respected.
 
 echo "${TEST_NAME} -- test whether EPYTHON is respected"
 

File tests/eselect-test

+#!/bin/sh
+
+echo "${TEST_NAME} -- test whether eselect-python is respected"
+
+# Usually, the newest version of Python is eselected. For that reason,
+# this test makes sense only if Python 3 is the main Python interpreter
+# (and thus a 'better' implementation could be selected).
+
+set -- ${PYTHON_IMPLS}
+
+SEL_PY=$(get_eselected)
+
+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 [ "${1}" = "${SEL_PY}" ]; then
+		break
+	else
+		shift
+	fi
+done
+
+ESELECT=${1}
+BETTER=${2}
+
+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}"