xonsh/run-tests.xsh
Noorhteen Raja NJ fd597e6971
chore (ci): improve ci workflows and deps management (#3873)
* chore (ci): improve elm job speed by caching

* chore (ci): update ci generator script to be run from any dir

* chore: update pre-commit to use local black binary

* chore: mypy config skip amalgam generated modules

* chore: run-tests.xsh parameterisation

use argparser to make this file a cli

* feat: use requirements.txt during CI

* feat: run black/flake8/mypy during ci from pip-env

* chore: mypy version 0.790 fix

since the loose pinning on mypy version causes new PRs to fail

* refactor: update github actions template

remove poetry/environment.yml files
2020-10-19 11:52:37 -04:00

72 lines
1.6 KiB
Python
Executable file

#!/usr/bin/env xonsh
import argparse
from typing import List
$RAISE_SUBPROC_ERROR = True
def _replace_args(args:List[str], num:int) -> List[str]:
return [
(arg % num) if "%d" in arg else arg
for arg in args
]
def test(ns: argparse.Namespace):
"""Run pytest.
Examples
--------
`xonsh run-tests.xsh -- --junitxml=junit/test-results.%%d.xml`
"""
run_separately = [
'tests/test_main.py',
'tests/test_ptk_highlight.py',
]
ignores = []
for fname in run_separately:
ignores.append('--ignore')
ignores.append(fname)
args = ns.args if "arg" in ns else []
![pytest @(_replace_args(args, 0)) @(ignores)]
for index, fname in enumerate(run_separately):
![pytest @(_replace_args(args, index+1)) @(fname)]
def qa(ns: argparse.Namespace):
"""QA checks"""
echo "---------- Check Black formatter -----------"
black --check xonsh xontrib
echo "---------- Running flake8 ----------"
python -m flake8
echo "---------- Running mypy ----------"
mypy --version
mypy xonsh
if __name__ == '__main__':
parser = argparse.ArgumentParser()
commands = parser.add_subparsers()
test_parser = commands.add_parser('test', help=test.__doc__)
test_parser.add_argument(
'pytest_args',
nargs='*',
help="arbitrary arguments that gets passed to pytest's invocation."
" Use %%d to parameterize and prevent overwrite "
)
test_parser.set_defaults(func=test)
qa_parser = commands.add_parser('qa', help=qa.__doc__)
qa_parser.set_defaults(func=qa)
args = parser.parse_args()
args.func(args)