From 47047ef5d1c3d868b0fecf14b8c8e6965fd75f67 Mon Sep 17 00:00:00 2001 From: Yen Chi Hsuan Date: Wed, 21 Oct 2015 00:37:28 +0800 Subject: [PATCH 1/5] [travis] Run tests in parallel --- devscripts/run_tests.sh | 2 +- test/test_download.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/devscripts/run_tests.sh b/devscripts/run_tests.sh index 7f4c1e083..f4f73484f 100755 --- a/devscripts/run_tests.sh +++ b/devscripts/run_tests.sh @@ -16,4 +16,4 @@ case "$YTDL_TEST_SET" in ;; esac -nosetests test --verbose $test_set +nosetests test --verbose $test_set --processes=4 --process-timeout=540 diff --git a/test/test_download.py b/test/test_download.py index 463952989..7decaf11e 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -65,6 +65,8 @@ defs = gettestcases() class TestDownload(unittest.TestCase): + _multiprocess_shared_ = True + maxDiff = None def setUp(self): From 841fff0a9dfd2fc276c0cdaef0843e3041621bd4 Mon Sep 17 00:00:00 2001 From: Yen Chi Hsuan Date: Thu, 22 Oct 2015 21:32:04 +0800 Subject: [PATCH 2/5] [test_download] Print test names in case of network errors --- test/test_download.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_download.py b/test/test_download.py index 7decaf11e..6876d050e 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -75,7 +75,7 @@ class TestDownload(unittest.TestCase): # Dynamically generate tests -def generator(test_case): +def generator(test_case, tname): def test_template(self): ie = youtube_dl.extractor.get_info_extractor(test_case['name']) @@ -148,7 +148,7 @@ def generator(test_case): raise if try_num == RETRIES: - report_warning('Failed due to network errors, skipping...') + report_warning('%s failed due to network errors, skipping...' % tname) return print('Retrying: {0} failed tries\n\n##########\n\n'.format(try_num)) @@ -223,12 +223,12 @@ def generator(test_case): # And add them to TestDownload for n, test_case in enumerate(defs): - test_method = generator(test_case) tname = 'test_' + str(test_case['name']) i = 1 while hasattr(TestDownload, tname): tname = 'test_%s_%d' % (test_case['name'], i) i += 1 + test_method = generator(test_case, tname) test_method.__name__ = str(tname) setattr(TestDownload, test_method.__name__, test_method) del test_method From 5c7a331dcde8660171b91069c804eeb069326be1 Mon Sep 17 00:00:00 2001 From: Yen Chi Hsuan Date: Sat, 24 Oct 2015 18:19:20 +0800 Subject: [PATCH 3/5] [test_download] Add comments for nose parameters --- test/test_download.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_download.py b/test/test_download.py index 6876d050e..b32016b2d 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -65,6 +65,8 @@ defs = gettestcases() class TestDownload(unittest.TestCase): + # Parallel testing in nosetests. See + # http://nose.readthedocs.org/en/latest/doc_tests/test_multiprocess/multiprocess.html _multiprocess_shared_ = True maxDiff = None From cdb0ba2119ab146fd8e03e85f8d065afdbf173d4 Mon Sep 17 00:00:00 2001 From: Yen Chi Hsuan Date: Tue, 3 Nov 2015 18:31:20 +0800 Subject: [PATCH 4/5] [test_download] Modify outtmpl to prevent info JSON filename conflicts Thanks @jaimeMF for the idea. --- test/test_download.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_download.py b/test/test_download.py index b32016b2d..30034f978 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -106,6 +106,7 @@ def generator(test_case, tname): return params = get_params(test_case.get('params', {})) + params['outtmpl'] = tname + '_' + params['outtmpl'] if is_playlist and 'playlist' not in test_case: params.setdefault('extract_flat', 'in_playlist') params.setdefault('skip_download', True) From f17ce2c5c3774525c947b0cb94d2d7dac1f013ea Mon Sep 17 00:00:00 2001 From: Yen Chi Hsuan Date: Sat, 18 Feb 2017 22:36:50 +0800 Subject: [PATCH 5/5] [travis] Only download tests should be run in parallel --- devscripts/run_tests.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/devscripts/run_tests.sh b/devscripts/run_tests.sh index f4f73484f..c60807215 100755 --- a/devscripts/run_tests.sh +++ b/devscripts/run_tests.sh @@ -3,6 +3,7 @@ DOWNLOAD_TESTS="age_restriction|download|subtitles|write_annotations|iqiyi_sdk_interpreter" test_set="" +multiprocess_args="" case "$YTDL_TEST_SET" in core) @@ -10,10 +11,11 @@ case "$YTDL_TEST_SET" in ;; download) test_set="-I test_(?!$DOWNLOAD_TESTS).+\.py" + multiprocess_args="--processes=4 --process-timeout=540" ;; *) break ;; esac -nosetests test --verbose $test_set --processes=4 --process-timeout=540 +nosetests test --verbose $test_set $multiprocess_args