|
4 | 4 | import sys
|
5 | 5 | from test.support import os_helper
|
6 | 6 |
|
| 7 | +from .utils import MS_WINDOWS |
| 8 | + |
7 | 9 |
|
8 | 10 | USAGE = """\
|
9 | 11 | python -m test [options] [test_name1 [test_name2 ...]]
|
|
145 | 147 |
|
146 | 148 | class Namespace(argparse.Namespace):
|
147 | 149 | def __init__(self, **kwargs) -> None:
|
| 150 | + self.ci = False |
148 | 151 | self.testdir = None
|
149 | 152 | self.verbose = 0
|
150 | 153 | self.quiet = False
|
@@ -209,6 +212,12 @@ def _create_parser():
|
209 | 212 | # We add help explicitly to control what argument group it renders under.
|
210 | 213 | group.add_argument('-h', '--help', action='help',
|
211 | 214 | help='show this help message and exit')
|
| 215 | + group.add_argument('--fast-ci', action='store_true', |
| 216 | + help='Fast Continuous Integration (CI) mode used by ' |
| 217 | + 'GitHub Actions') |
| 218 | + group.add_argument('--slow-ci', action='store_true', |
| 219 | + help='Slow Continuous Integration (CI) mode used by ' |
| 220 | + 'buildbot workers') |
212 | 221 | group.add_argument('--timeout', metavar='TIMEOUT', type=float,
|
213 | 222 | help='dump the traceback and exit if a test takes '
|
214 | 223 | 'more than TIMEOUT seconds; disabled if TIMEOUT '
|
@@ -386,6 +395,37 @@ def _parse_args(args, **kwargs):
|
386 | 395 | parser.error("unrecognized arguments: %s" % arg)
|
387 | 396 | sys.exit(1)
|
388 | 397 |
|
| 398 | + # Continuous Integration (CI): common options for fast/slow CI modes |
| 399 | + if ns.slow_ci or ns.fast_ci: |
| 400 | + # Similar to options: |
| 401 | + # |
| 402 | + # -j0 --rerun -r --fail-env-changed --fail-rerun --slowest |
| 403 | + # --verbose3 --nowindows |
| 404 | + if ns.use_mp is None: |
| 405 | + ns.use_mp = 0 |
| 406 | + ns.rerun = True |
| 407 | + ns.randomize = True |
| 408 | + ns.fail_env_changed = True |
| 409 | + ns.fail_rerun = True |
| 410 | + ns.print_slow = True |
| 411 | + ns.verbose3 = True |
| 412 | + if MS_WINDOWS: |
| 413 | + ns.nowindows = True # Silence alerts under Windows |
| 414 | + |
| 415 | + # When --slow-ci and --fast-ci are present, --slow-ci has the priority |
| 416 | + if ns.slow_ci: |
| 417 | + # Similar to: -u "all" --timeout=1200 |
| 418 | + if not ns.use: |
| 419 | + ns.use = [['all']] |
| 420 | + if ns.timeout is None: |
| 421 | + ns.timeout = 1200 # 20 minutes |
| 422 | + elif ns.fast_ci: |
| 423 | + # Similar to: -u "all,-cpu" --timeout=600 |
| 424 | + if not ns.use: |
| 425 | + ns.use = [['all', '-cpu']] |
| 426 | + if ns.timeout is None: |
| 427 | + ns.timeout = 600 # 10 minutes |
| 428 | + |
389 | 429 | if ns.single and ns.fromfile:
|
390 | 430 | parser.error("-s and -f don't go together!")
|
391 | 431 | if ns.use_mp is not None and ns.trace:
|
|
0 commit comments