| 496 | |
| 497 | |
| 498 | def parse_args(): |
| 499 | parser = argparse.ArgumentParser(prog='runner.py', description=__doc__) |
| 500 | parser.add_argument('--save-dir', action='store_true', |
| 501 | help='Save the temporary directory used during for each ' |
| 502 | 'test. Implies --cores=1. Defaults to true when running a single test') |
| 503 | parser.add_argument('--no-clean', action='store_true', |
| 504 | help='Do not clean the temporary directory before each test run') |
| 505 | parser.add_argument('--verbose', '-v', action='count', default=0, |
| 506 | help="Show test stdout and stderr, and don't use the single-line test reporting. " |
| 507 | 'Specifying `-v` twice will enable test framework logging (i.e. EMTEST_VERBOSE)') |
| 508 | parser.add_argument('--ansi', action=argparse.BooleanOptionalAction, default=None) |
| 509 | parser.add_argument('--all-engines', action='store_true') |
| 510 | parser.add_argument('--detect-leaks', action='store_true') |
| 511 | parser.add_argument('--skip-slow', action='store_true', help='Skip tests marked as slow') |
| 512 | parser.add_argument('--cores', '-j', |
| 513 | help='Set the number tests to run in parallel. Defaults ' |
| 514 | 'to the number of CPU cores.', default=None) |
| 515 | parser.add_argument('--rebaseline', action='store_true', |
| 516 | help='Automatically update test expectations for tests that support it.') |
| 517 | parser.add_argument('--browser', |
| 518 | help='Command to launch web browser in which to run browser tests.') |
| 519 | parser.add_argument('--headless', action='store_true', |
| 520 | help='Run browser tests in headless mode.', default=None) |
| 521 | parser.add_argument('--browser-auto-config', action=argparse.BooleanOptionalAction, default=None, |
| 522 | help='Use the default CI browser configuration.') |
| 523 | parser.add_argument('tests', nargs='*') |
| 524 | parser.add_argument('--failfast', action='store_true', help='If true, test run will abort on first failed test.') |
| 525 | parser.add_argument('--max-failures', type=int, default=2**31 - 1, help='If specified, test run will abort after N failed tests.') |
| 526 | parser.add_argument('--failing-and-slow-first', action='store_true', help='Run failing tests first, then sorted by slowest first. Combine with --failfast for fast fail-early CI runs.') |
| 527 | parser.add_argument('--start-at', metavar='NAME', help='Skip all tests up until <NAME>') |
| 528 | parser.add_argument('--continue', dest='_continue', action='store_true', |
| 529 | help='Resume from the last run test.' |
| 530 | 'Useful when combined with --failfast') |
| 531 | parser.add_argument('--crossplatform-only', action='store_true') |
| 532 | parser.add_argument('--log-test-environment', action='store_true', help='Prints out detailed information about the current environment. Useful for adding more info to CI test runs.') |
| 533 | parser.add_argument('--force-browser-process-termination', action='store_true', help='If true, a fail-safe method is used to ensure that all browser processes are terminated before and after the test suite run. Note that this option will terminate all browser processes, not just those launched by the harness, so will result in loss of all open browsing sessions.') |
| 534 | parser.add_argument('--repeat', type=int, default=1, |
| 535 | help='Repeat each test N times (default: 1).') |
| 536 | parser.add_argument('--bell', action='store_true', help='Play a sound after the test suite finishes.') |
| 537 | |
| 538 | options = parser.parse_args() |
| 539 | |
| 540 | if options.ansi is None: |
| 541 | options.ansi = colored_logger.ansi_color_available() |
| 542 | else: |
| 543 | if options.ansi: |
| 544 | colored_logger.enable(force=True) |
| 545 | else: |
| 546 | colored_logger.disable() |
| 547 | |
| 548 | if options.failfast: |
| 549 | if options.max_failures != 2**31 - 1: |
| 550 | utils.exit_with_error('--failfast and --max-failures are mutually exclusive!') |
| 551 | options.max_failures = 0 |
| 552 | |
| 553 | return options |
| 554 | |
| 555 | |