Commits

Michał Górny committed 9aebbba

Tests: check whether default preference order is respected.

  • Participants
  • Parent commits 4c11221

Comments (0)

Files changed (2)

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

File tests/order-test

+#!/bin/sh
+
+echo "${TEST_NAME} -- test whether default preference order is respected"
+
+set -- ${PYTHON_IMPLS}
+
+SEL_PY2=$(get_eselected --python2)
+SEL_PY3=$(get_eselected --python3)
+
+unset FIRST
+while true; do
+	if [ ${#} -lt 1 ]; then
+		echo 'Not enough implementations to perform test.' >&2
+		do_exit 77
+	fi
+
+	# we need to find two not-selected implementations.
+	if [ "${1}" = "${SEL_PY2}" -o "${1}" = "${SEL_PY3}" ]; then
+		shift
+	else
+		if [ -n "${FIRST}" ]; then
+			SECOND=${1}
+			break
+		else
+			FIRST=${1}
+			shift
+		fi
+	fi
+done
+
+echo "first: ${FIRST}" >&2
+echo "second: ${SECOND}" >&2
+
+unset EPYTHON
+
+write_impl "${FIRST}" "#!/usr/bin/env false"
+write_impl "${SECOND}"  "#!/usr/bin/env true"
+
+do_test "${TEST_TMP}"