|
31 | 31 | from __future__ import print_function |
32 | 32 | from typing import Dict |
33 | 33 | import logging |
34 | | -import optparse |
| 34 | +import argparse |
35 | 35 | import os |
36 | 36 | import re |
37 | 37 | import signal |
@@ -1378,84 +1378,84 @@ def ReadConfigurationInto(path, sections, defs): |
1378 | 1378 |
|
1379 | 1379 |
|
1380 | 1380 | def BuildOptions(): |
1381 | | - result = optparse.OptionParser() |
1382 | | - result.add_option("-m", "--mode", help="The test modes in which to run (comma-separated)", |
| 1381 | + result = argparse.ArgumentParser() |
| 1382 | + result.add_argument("-m", "--mode", help="The test modes in which to run (comma-separated)", |
1383 | 1383 | default='release') |
1384 | | - result.add_option("-v", "--verbose", help="Verbose output", |
| 1384 | + result.add_argument("-v", "--verbose", help="Verbose output", |
1385 | 1385 | default=False, action="store_true") |
1386 | | - result.add_option('--logfile', dest='logfile', |
| 1386 | + result.add_argument('--logfile', dest='logfile', |
1387 | 1387 | help='write test output to file. NOTE: this only applies the tap progress indicator') |
1388 | | - result.add_option("-p", "--progress", |
| 1388 | + result.add_argument("-p", "--progress", |
1389 | 1389 | help="The style of progress indicator (%s)" % ", ".join(PROGRESS_INDICATORS.keys()), |
1390 | 1390 | choices=list(PROGRESS_INDICATORS.keys()), default="mono") |
1391 | | - result.add_option("--report", help="Print a summary of the tests to be run", |
| 1391 | + result.add_argument("--report", help="Print a summary of the tests to be run", |
1392 | 1392 | default=False, action="store_true") |
1393 | | - result.add_option("-s", "--suite", help="A test suite", |
| 1393 | + result.add_argument("-s", "--suite", help="A test suite", |
1394 | 1394 | default=[], action="append") |
1395 | | - result.add_option("-t", "--timeout", help="Timeout in seconds", |
1396 | | - default=120, type="int") |
1397 | | - result.add_option("--arch", help='The architecture to run tests for', |
| 1395 | + result.add_argument("-t", "--timeout", help="Timeout in seconds", |
| 1396 | + default=120, type=int) |
| 1397 | + result.add_argument("--arch", help='The architecture to run tests for', |
1398 | 1398 | default='none') |
1399 | | - result.add_option("--snapshot", help="Run the tests with snapshot turned on", |
| 1399 | + result.add_argument("--snapshot", help="Run the tests with snapshot turned on", |
1400 | 1400 | default=False, action="store_true") |
1401 | | - result.add_option("--special-command", default=None) |
1402 | | - result.add_option("--node-args", dest="node_args", help="Args to pass through to Node", |
| 1401 | + result.add_argument("--special-command", default=None) |
| 1402 | + result.add_argument("--node-args", dest="node_args", help="Args to pass through to Node", |
1403 | 1403 | default=[], action="append") |
1404 | | - result.add_option("--expect-fail", dest="expect_fail", |
| 1404 | + result.add_argument("--expect-fail", dest="expect_fail", |
1405 | 1405 | help="Expect test cases to fail", default=False, action="store_true") |
1406 | | - result.add_option("--valgrind", help="Run tests through valgrind", |
| 1406 | + result.add_argument("--valgrind", help="Run tests through valgrind", |
1407 | 1407 | default=False, action="store_true") |
1408 | | - result.add_option("--worker", help="Run parallel tests inside a worker context", |
| 1408 | + result.add_argument("--worker", help="Run parallel tests inside a worker context", |
1409 | 1409 | default=False, action="store_true") |
1410 | | - result.add_option("--check-deopts", help="Check tests for permanent deoptimizations", |
| 1410 | + result.add_argument("--check-deopts", help="Check tests for permanent deoptimizations", |
1411 | 1411 | default=False, action="store_true") |
1412 | | - result.add_option("--cat", help="Print the source of the tests", |
| 1412 | + result.add_argument("--cat", help="Print the source of the tests", |
1413 | 1413 | default=False, action="store_true") |
1414 | | - result.add_option("--flaky-tests", |
| 1414 | + result.add_argument("--flaky-tests", |
1415 | 1415 | help="Regard tests marked as flaky (run|skip|dontcare|keep_retrying)", |
1416 | 1416 | default="run") |
1417 | | - result.add_option("--measure-flakiness", |
| 1417 | + result.add_argument("--measure-flakiness", |
1418 | 1418 | help="When a test fails, re-run it x number of times", |
1419 | | - default=0, type="int") |
1420 | | - result.add_option("--skip-tests", |
| 1419 | + default=0, type=int) |
| 1420 | + result.add_argument("--skip-tests", |
1421 | 1421 | help="Tests that should not be executed (comma-separated)", |
1422 | 1422 | default="") |
1423 | | - result.add_option("--warn-unused", help="Report unused rules", |
| 1423 | + result.add_argument("--warn-unused", help="Report unused rules", |
1424 | 1424 | default=False, action="store_true") |
1425 | | - result.add_option("-j", help="The number of parallel tasks to run, 0=use number of cores", |
1426 | | - default=0, type="int") |
1427 | | - result.add_option("-J", help="For legacy compatibility, has no effect", |
| 1425 | + result.add_argument("-j", help="The number of parallel tasks to run, 0=use number of cores", |
| 1426 | + default=0, type=int) |
| 1427 | + result.add_argument("-J", help="For legacy compatibility, has no effect", |
1428 | 1428 | default=False, action="store_true") |
1429 | | - result.add_option("--time", help="Print timing information after running", |
| 1429 | + result.add_argument("--time", help="Print timing information after running", |
1430 | 1430 | default=False, action="store_true") |
1431 | | - result.add_option("--suppress-dialogs", help="Suppress Windows dialogs for crashing tests", |
| 1431 | + result.add_argument("--suppress-dialogs", help="Suppress Windows dialogs for crashing tests", |
1432 | 1432 | dest="suppress_dialogs", default=True, action="store_true") |
1433 | | - result.add_option("--no-suppress-dialogs", help="Display Windows dialogs for crashing tests", |
| 1433 | + result.add_argument("--no-suppress-dialogs", help="Display Windows dialogs for crashing tests", |
1434 | 1434 | dest="suppress_dialogs", action="store_false") |
1435 | | - result.add_option("--shell", help="Path to node executable", default=None) |
1436 | | - result.add_option("--store-unexpected-output", |
| 1435 | + result.add_argument("--shell", help="Path to node executable", default=None) |
| 1436 | + result.add_argument("--store-unexpected-output", |
1437 | 1437 | help="Store the temporary JS files from tests that fails", |
1438 | 1438 | dest="store_unexpected_output", default=True, action="store_true") |
1439 | | - result.add_option("--no-store-unexpected-output", |
| 1439 | + result.add_argument("--no-store-unexpected-output", |
1440 | 1440 | help="Deletes the temporary JS files from tests that fails", |
1441 | 1441 | dest="store_unexpected_output", action="store_false") |
1442 | | - result.add_option("-r", "--run", |
| 1442 | + result.add_argument("-r", "--run", |
1443 | 1443 | help="Divide the tests in m groups (interleaved) and run tests from group n (--run=n,m with n < m)", |
1444 | 1444 | default="") |
1445 | | - result.add_option('--temp-dir', |
| 1445 | + result.add_argument('--temp-dir', |
1446 | 1446 | help='Optional path to change directory used for tests', default=False) |
1447 | | - result.add_option('--test-root', |
| 1447 | + result.add_argument('--test-root', |
1448 | 1448 | help='Optional path to change test directory', dest='test_root', default=None) |
1449 | | - result.add_option('--repeat', |
| 1449 | + result.add_argument('--repeat', |
1450 | 1450 | help='Number of times to repeat given tests', |
1451 | | - default=1, type="int") |
1452 | | - result.add_option('--abort-on-timeout', |
| 1451 | + default=1, type=int) |
| 1452 | + result.add_argument('--abort-on-timeout', |
1453 | 1453 | help='Send SIGABRT instead of SIGTERM to kill processes that time out', |
1454 | 1454 | default=False, action="store_true", dest="abort_on_timeout") |
1455 | | - result.add_option("--type", |
| 1455 | + result.add_argument("--type", |
1456 | 1456 | help="Type of build (simple, fips, coverage)", |
1457 | 1457 | default=None) |
1458 | | - result.add_option("--error-reporter", |
| 1458 | + result.add_argument("--error-reporter", |
1459 | 1459 | help="use error reporter", |
1460 | 1460 | default=True, action="store_true") |
1461 | 1461 | return result |
@@ -1634,7 +1634,7 @@ def get_pointer_compression_state(vm, context): |
1634 | 1634 |
|
1635 | 1635 | def Main(): |
1636 | 1636 | parser = BuildOptions() |
1637 | | - (options, args) = parser.parse_args() |
| 1637 | + (options, args) = parser.parse_known_args() |
1638 | 1638 | if not ProcessOptions(options): |
1639 | 1639 | parser.print_help() |
1640 | 1640 | return 1 |
|
0 commit comments