From b3aa5d9185a1fb5ccc3f50d31f5ed23bc1a4e6c6 Mon Sep 17 00:00:00 2001 From: Olof Johansson Date: Wed, 19 Mar 2014 23:16:00 +0100 Subject: [PATCH] Default to always run unit tests for both py2 and 3 --- Makefile | 6 +++++- run-tests.sh | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 6093f65..51145dc 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,10 @@ export PYTHONPATH=lib # Disable convention, refactor, and TODO warnings PYLINT_OPTS = -d I -d C -d R -d W0511 +# If you don't have a python3 environment (e.g. mock for py3 and +# nosetests3), you can remove the -3 flag. +TEST_OPTS = -2 -3 + install: svtplay-dl $(MANFILE) install -d $(DESTDIR)$(BINDIR) install -d $(DESTDIR)$(MANDIR) @@ -44,7 +48,7 @@ svtplay-dl.1.gz: svtplay-dl.1 gzip -9 svtplay-dl.1 test: - sh run-tests.sh + sh run-tests.sh $(TEST_OPTS) cover: sh run-tests.sh -C diff --git a/run-tests.sh b/run-tests.sh index 578b5e1..66ee676 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -9,12 +9,15 @@ die() { COVER_OPTS="--with-coverage --cover-package=svtplay_dl" -NOSETESTS=nosetests +NOSETESTS= while [ "$#" -gt 0 ]; do case $1 in + -2) + NOSETESTS="$NOSETESTS nosetests" + ;; -3) - NOSETESTS=nosetests3 + NOSETESTS="$NOSETESTS nosetests3" ;; -c|--coverage) OPTS="$OPTS $COVER_OPTS" @@ -35,4 +38,13 @@ while [ "$#" -gt 0 ]; do shift done -PYTHONPATH=lib $NOSETESTS $OPTS +# Default to only run for python2 +NOSETESTS=${NOSETESTS:-nosetests} + +tests_ok=y +for nose in $NOSETESTS; do + PYTHONPATH=lib $nose $OPTS + [ $? -eq 0 ] || tests_ok= +done + +[ "$tests_ok" = y ]