Skip to content

Commit

Permalink
.ci/get_tests.py: Add dynamic test skip list
Browse files Browse the repository at this point in the history
Custom rules in tox.ini are migrated into get_tests.py so
that they can be dynamically collated together.

Disable phpmd test test_cleancode_violation, as it is currently
failing due to a minor text change in the error emitted by the
linter.

Related to coala#2943
Related to coala#1476
  • Loading branch information
jayvdb committed Aug 5, 2019
1 parent 28fdbc6 commit f672689
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
29 changes: 28 additions & 1 deletion .ci/get_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,34 @@ def get_tests(bears):
return tests


def get_pytest_deselected_tests(args, tests):
not_list = []
if 'tests/documentation/DocGrammarBearTest.py' in tests:
if 'win' in args:
not_list.append('test_language_french')

if 'tests/python/YapfBearTest.py' in tests:
if 'py34' in args:
not_list.append('test_valid_async')

if 'tests/php/PHPMessDetectorBearTest.py' in tests:
not_list.append('test_cleancode_violation')

return not_list


def main():
args_orig = sys.argv[1:]
metadata = get_metadata()

include_disabled = False
show_deselected = False
if args_orig[0] == '--disabled':
include_disabled = True
args_orig = args_orig[1:]
elif args_orig[0] == '--deselected':
show_deselected = True
args_orig = args_orig[1:]

args = []
for arg in args_orig:
Expand All @@ -149,7 +169,14 @@ def main():

bears = get_bears(metadata, args, include_disabled)
tests = get_tests(bears)
print(' '.join(sorted(tests)))
if show_deselected:
not_list = get_pytest_deselected_tests(args, tests)
if len(not_list) > 1:
print('-k "not ({})"'.format(' or '.join(not_list)))
elif len(not_list) == 1:
print('-k "not {}"'.format(not_list[0]))
else:
print(' '.join(sorted(tests)))


if __name__ == '__main__':
Expand Down
5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,17 @@ deps =
setenv =
LINTR_COMMENT_BOT=false
ENVNAMEBEARS=`python .ci/get_tests.py {envname}`
PYTEST_DESELECT_ARG=`python .ci/get_tests.py --deselected {envname}`
adhoc: ADHOCBEARS=`python .ci/get_tests.py {env:BEAR_LIST}`
disabled: DISABLEDBEARS=`python .ci/get_tests.py --disabled {env:BEAR_LIST}`
SELECTED={env:ENVNAMEBEARS:} {env:ADHOCBEARS:} {env:DISABLEDBEARS:}
noskip: PYTEST_ARGS=--error-for-skips
py34-noskip: PYTEST_ARGS=--error-for-skips -k 'not test_valid_async'
win-noskip: PYTEST_ARGS=--error-for-skips -k 'not test_language_french and not test_valid_async'
collectonly,list: PYTEST_ARGS=--collect-only
codecov: CODECOV_FLAGS=`python .ci/get_codecov_tags.py {envname}`
commands =
check,list,all: python .ci/get_bears.py --missing {env:SELECTED}
!py34,!apt_get: python .ci/generate_coverage_thresholds.py {posargs:{env:SELECTED}}
py34,apt_get: python .ci/generate_coverage_thresholds.py none
!list: pytest {env:PYTEST_ARGS:} --cov --cov-fail-under=0 --continue-on-collection-errors --cov-report term-missing:skip-covered --deselect=requirements.txt {posargs:{env:SELECTED}}
!list: pytest {env:PYTEST_ARGS:} --cov --cov-fail-under=0 --continue-on-collection-errors --cov-report term-missing:skip-covered --deselect=requirements.txt {posargs:{env:SELECTED}} {env:PYTEST_DESELECT_ARG:}
commands_post =
codecov: codecov --name={envname} --flags={env:CODECOV_FLAGS}

0 comments on commit f672689

Please sign in to comment.