From 8ef790de12591887af2c5fb30872911d64475b53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 19 Mar 2018 17:57:32 +0100 Subject: [PATCH] update .travis.yml - restrict builds to master branch and release tags - implement 'core' and 'results' test categories --- .travis.yml | 31 +++++++++++++------- scripts/run_tests.sh | 24 +++++++++++++++ test/{test_extractors.py => test_results.py} | 7 +++-- 3 files changed, 48 insertions(+), 14 deletions(-) create mode 100755 scripts/run_tests.sh rename test/{test_extractors.py => test_results.py} (97%) diff --git a/.travis.yml b/.travis.yml index 203af806..f1aebd19 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,23 @@ -sudo: false language: python python: - - 3.3 - - 3.4 - - 3.5 - - 3.6 -install: - - pip install -r requirements.txt -script: - - if [[ $TRAVIS_PYTHON_VERSION != '3.6' ]]; then nosetests --ignore-files=test_extractors --verbose test; fi - - if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then nosetests --verbose test; fi + - "3.3" + - "3.4" + - "3.5" + - "3.6" +env: + - GALLERYDL_TESTS=core +matrix: + include: + - python: "3.6" + - env: GALLERYDL_TESTS=results + +sudo: false git: - depth: 10 + depth: 3 +branches: + only: + - master + - /^v\d+\.\d+\.\d+(-\S*)?$/ + +script: + - ./scripts/run_tests.sh diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh new file mode 100755 index 00000000..89a40be7 --- /dev/null +++ b/scripts/run_tests.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +ROOTDIR="$(realpath "$(dirname "$0")/..")/" + +TESTS_CORE=(config cookies oauth text util) +TESTS_RESULTS=(extractors) + + +# select tests +TESTS=() +case "${GALLERYDL_TESTS}" in + core) TESTS=( ${TESTS_CORE[@]} );; + results) TESTS=( ${TESTS_RESULTS[@]} );; +esac + + +# transform each array element to test_###.py +TESTS=( ${TESTS[@]/#/test_} ) +TESTS=( ${TESTS[@]/%/.py} ) + + +# run 'nosetests' with selected tests +# (or all tests if ${TESTS} is empty) +nosetests --verbose -w "${ROOTDIR}/test/" ${TESTS[@]} diff --git a/test/test_extractors.py b/test/test_results.py similarity index 97% rename from test/test_extractors.py rename to test/test_results.py index 33eaca95..3962d689 100644 --- a/test/test_extractors.py +++ b/test/test_results.py @@ -21,11 +21,12 @@ TRAVIS_SKIP = { # temporary issues, etc. BROKEN = { + "mangapark", "puremashiro", # online reader down } -class TestExtractors(unittest.TestCase): +class TestExtractorResults(unittest.TestCase): def setUp(self): name = "gallerydl" @@ -159,7 +160,7 @@ def generate_tests(): ) ] - # add 'test_...' methods to TestExtractors + # add 'test_...' methods for extr in extractors: if not hasattr(extr, "test") or not extr.test: continue @@ -167,7 +168,7 @@ def generate_tests(): for num, tcase in enumerate(extr.test, 1): test = _generate_test(extr, tcase) test.__name__ = name + str(num) - setattr(TestExtractors, test.__name__, test) + setattr(TestExtractorResults, test.__name__, test) generate_tests()