Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathruntests.py
More file actions
Latest commit
executable file
·127 lines (104 loc) · 2.93 KB
/
Copy pathruntests.py
File metadata and controls
executable file
·127 lines (104 loc) · 2.93 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/python3 -u
"""
Run the test suite on multiple Python versions.
Usage::
python3 runtests.py
python3 runtests.py --verbose
python3 runtests.py --current --verbose
"""
from __future__ importabsolute_import
from __future__ importprint_function
importargparse
importos.path
importshutil
importsys
try:
fromshutilimportwhich
exceptImportError:
# Python 2
fromdistutils.spawnimportfind_executableaswhich
fromtests.utilsimportrun_command
TEST_DIR=os.path.join(os.path.dirname(__file__), 'tests')
TEST_COMPAT=os.path.join(TEST_DIR, "test_pythoncapi_compat.py")
TEST_UPGRADE=os.path.join(TEST_DIR, "test_upgrade_pythoncapi.py")
PYTHONS= (
# CPython
"python3-debug",
"python3",
"python2.7",
"python3.6",
"python3.7",
"python3.8",
"python3.9",
"python3.10",
"python3.11",
"python3.12",
"python3.13",
"python3.13t",
"python3.14",
"python3.14t",
"python3.15",
"python3.15t",
# PyPy
"pypy",
"pypy2",
"pypy2.7",
"pypy3",
"pypy3.6",
"pypy3.7",
"pypy3.8",
"pypy3.9",
"pypy3.10",
"pypy3.11",
)
defrun_tests_exe(executable, verbose, tested):
tested_key=os.path.realpath(executable)
iftested_keyintested:
return
# Don't use realpath() for the executed command to support virtual
# environments
cmd= [executable, TEST_COMPAT]
ifverbose:
cmd.append('-v')
run_command(cmd)
tested.add(tested_key)
defrun_tests(python, verbose, tested):
executable=which(python)
ifnotexecutable:
print("Ignore missing Python executable: %s"%python)
return
run_tests_exe(executable, verbose, tested)
defparse_args():
parser=argparse.ArgumentParser()
parser.add_argument('-v', '--verbose', action="store_true",
help='Verbose mode')
parser.add_argument('-c', '--current', action="store_true",
help="Only test the current Python executable "
"(don't test multiple Python versions)")
returnparser.parse_args()
defmain():
args=parse_args()
path=os.path.join(TEST_DIR, 'build')
ifos.path.exists(path):
shutil.rmtree(path)
# upgrade_pythoncapi.py requires Python 3.6 or newer
ifsys.version_info>= (3, 6):
print("Run %s"%TEST_UPGRADE)
cmd= [sys.executable, TEST_UPGRADE]
ifargs.verbose:
cmd.append('-v')
run_command(cmd)
else:
print("Don't test upgrade_pythoncapi.py: it requires Python 3.6")
print()
tested=set()
ifnotargs.current:
forpythoninPYTHONS:
run_tests(python, args.verbose, tested)
run_tests_exe(sys.executable, args.verbose, tested)
print()
print("Tested: %s Python executables"%len(tested))
else:
run_tests_exe(sys.executable, args.verbose, tested)
if__name__=="__main__":
main()