-
Notifications
You must be signed in to change notification settings - Fork 1
/
pytest
executable file
·45 lines (37 loc) · 1.29 KB
/
pytest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
"""": # -*-python-*-
set -eu
# Changes here might also be appropriate for ./pylint
script_home="$(cd "$(dirname "$0")" && pwd -P)"
testlibdir="$script_home/test/lib"
export PYTHONPATH="$testlibdir${PYTHONPATH:+:$PYTHONPATH}"
# Guard against accidentally using/testing a local bup
export PATH="$(dirname "$0")/dev/shadow-bin:$PATH"
exec dev/bup-python "$0" ${1+"$@"}
"""
import pytest, shlex, sys, os
argv = ['-v', '-m', 'not release']
## Drop all xdist related opts if xdist isn't available. Otherwise
## default to worksteal if the version's new enough since it claims,
## and appears, to handle test sets with more widely varying run times
## better.
try:
import xdist
xdist_ver = xdist.__version__.split('.')
if xdist_ver >= ['3', '2', '1']: # #884: Fixed hang in worksteal scheduler
argv.extend(('--dist', 'worksteal'))
argv.extend(sys.argv[1:])
except ModuleNotFoundError: # delete all -n opts
i = 1
while i < len(sys.argv):
arg = sys.argv[i]
if arg == '-n':
i += 2
elif arg.startswith('-n'):
i += 1
else:
argv.append(sys.argv[i])
i += 1
if os.environ.get('V') == '1':
print(' '.join([shlex.quote(x) for x in ['pytest'] + argv]), file=sys.stderr)
sys.exit(pytest.main(args=argv))