runtests.sh: use 0 to control arg parse loop
[portage.git] / runtests.sh
1 #!/bin/bash
2 # Copyright 2010-2011 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 PYTHON_VERSIONS="2.6 2.7 3.1 3.2 3.3"
6
7 # has to be run from portage root dir
8 cd "${0%/*}" || exit 1
9
10 case "${NOCOLOR:-false}" in
11         yes|true)
12                 GOOD=
13                 BAD=
14                 NORMAL=
15                 ;;
16         no|false)
17                 GOOD=$'\e[1;32m'
18                 BAD=$'\e[1;31m'
19                 NORMAL=$'\e[0m'
20                 ;;
21 esac
22
23 interrupted() {
24         echo "interrupted." >&2
25         exit 1
26 }
27
28 trap interrupted SIGINT
29
30 unused_args=()
31
32 while [ $# -gt 0 ] ; do
33         case "$1" in
34                 --python-versions=*)
35                         PYTHON_VERSIONS=${1#--python-versions=}
36                         ;;
37                 --python-versions)
38                         shift
39                         PYTHON_VERSIONS=$1
40                         ;;
41                 *)
42                         unused_args[${#unused_args[@]}]=$1
43                         ;;
44         esac
45         shift
46 done
47
48 set -- "${unused_args[@]}"
49
50 exit_status="0"
51 for version in ${PYTHON_VERSIONS}; do
52         if [[ -x /usr/bin/python${version} ]]; then
53                 echo -e "${GOOD}Testing with Python ${version}...${NORMAL}"
54                 if ! /usr/bin/python${version} -Wd pym/portage/tests/runTests "$@" ; then
55                         echo -e "${BAD}Testing with Python ${version} failed${NORMAL}"
56                         exit_status="1"
57                 fi
58                 echo
59         fi
60 done
61
62 exit ${exit_status}