commit 903e5e4c2b943a06738386a14104304b4f3ef80a
Author: Michal Srb <msrb(a)redhat.com>
Date: Wed Jul 23 10:39:11 2014 +0200
[test] Add support for python 3 to ./check script
check | 5 +++-
test/run_tests.sh | 26 +-----------------------
test/test_common.sh | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 58 insertions(+), 25 deletions(-)
---
diff --git a/check b/check
index 508c548..01d3326 100755
--- a/check
+++ b/check
@@ -35,8 +35,11 @@ if ! test -f config.status; then
exit 1
fi
. ./config.status
+. ./test/test_common.sh
+f_set_python $1
-(cd ./python && python setup.py test)
+echo "running python tests with ${python}"
+(cd ./python && ${python} setup.py test)
r1=$?
r1=0
(cd ./test && ./run_tests.sh ${1})
diff --git a/test/run_tests.sh b/test/run_tests.sh
index 8fe9417..4525679 100755
--- a/test/run_tests.sh
+++ b/test/run_tests.sh
@@ -31,30 +31,8 @@
#
# Authors: Michal Srb <msrb(a)redhat.com>
-
-usage() {
- echo "$0 [2|3]"
- echo "2 - run tests with python 2 (default)"
- echo "3 - run tests with python 3"
-}
-
-# default is still python 2
-python="/usr/bin/python"
-
-if [ "$1" != "" ]; then
- case $1 in
- 2)
- python=${python}
- ;;
- 3)
- python="/usr/bin/python3"
- ;;
- *)
- echo "Invalid argument: $1"
- usage
- exit 1
- esac
-fi
+. test_common.sh
+f_set_python $1
echo "running tests with ${python}"
PYTHONPATH="../python" ${python} run_tests.py
diff --git a/test/test_common.sh b/test/test_common.sh
new file mode 100644
index 0000000..b93c524
--- /dev/null
+++ b/test/test_common.sh
@@ -0,0 +1,52 @@
+#!/usr/bin/sh
+# Copyright (c) 2014, Red Hat, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the
+# distribution.
+# 3. Neither the name of Red Hat nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# Authors: Michal Srb <msrb(a)redhat.com>
+
+f_set_python() {
+ # default is still python 2
+ python="/usr/bin/python"
+ if [ "$1" != "" ]; then
+ case $1 in
+ 2)
+ python=${python}
+ ;;
+ 3)
+ python="/usr/bin/python3"
+ ;;
+ *)
+ echo "Invalid argument: $1"
+ echo "$0 [2|3]"
+ echo "2 - run tests with python 2 (default)"
+ echo "3 - run tests with python 3"
+ exit 1
+ esac
+ fi
+}