test: switch from deprecated `optparse` to `argparse` · nodejs/node@029440b
@@ -31,7 +31,7 @@
3131from __future__ import print_function
3232from typing import Dict
3333import logging
34-import optparse
34+import argparse
3535import os
3636import re
3737import signal
@@ -1378,84 +1378,84 @@ def ReadConfigurationInto(path, sections, defs):
137813781379137913801380def 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)",
13831383default='release')
1384-result.add_option("-v", "--verbose", help="Verbose output",
1384+result.add_argument("-v", "--verbose", help="Verbose output",
13851385default=False, action="store_true")
1386-result.add_option('--logfile', dest='logfile',
1386+result.add_argument('--logfile', dest='logfile',
13871387help='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",
13891389help="The style of progress indicator (%s)" % ", ".join(PROGRESS_INDICATORS.keys()),
13901390choices=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",
13921392default=False, action="store_true")
1393-result.add_option("-s", "--suite", help="A test suite",
1393+result.add_argument("-s", "--suite", help="A test suite",
13941394default=[], 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',
13981398default='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",
14001400default=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",
14031403default=[], action="append")
1404-result.add_option("--expect-fail", dest="expect_fail",
1404+result.add_argument("--expect-fail", dest="expect_fail",
14051405help="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",
14071407default=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",
14091409default=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",
14111411default=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",
14131413default=False, action="store_true")
1414-result.add_option("--flaky-tests",
1414+result.add_argument("--flaky-tests",
14151415help="Regard tests marked as flaky (run|skip|dontcare|keep_retrying)",
14161416default="run")
1417-result.add_option("--measure-flakiness",
1417+result.add_argument("--measure-flakiness",
14181418help="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",
14211421help="Tests that should not be executed (comma-separated)",
14221422default="")
1423-result.add_option("--warn-unused", help="Report unused rules",
1423+result.add_argument("--warn-unused", help="Report unused rules",
14241424default=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",
14281428default=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",
14301430default=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",
14321432dest="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",
14341434dest="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",
14371437help="Store the temporary JS files from tests that fails",
14381438dest="store_unexpected_output", default=True, action="store_true")
1439-result.add_option("--no-store-unexpected-output",
1439+result.add_argument("--no-store-unexpected-output",
14401440help="Deletes the temporary JS files from tests that fails",
14411441dest="store_unexpected_output", action="store_false")
1442-result.add_option("-r", "--run",
1442+result.add_argument("-r", "--run",
14431443help="Divide the tests in m groups (interleaved) and run tests from group n (--run=n,m with n < m)",
14441444default="")
1445-result.add_option('--temp-dir',
1445+result.add_argument('--temp-dir',
14461446help='Optional path to change directory used for tests', default=False)
1447-result.add_option('--test-root',
1447+result.add_argument('--test-root',
14481448help='Optional path to change test directory', dest='test_root', default=None)
1449-result.add_option('--repeat',
1449+result.add_argument('--repeat',
14501450help='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',
14531453help='Send SIGABRT instead of SIGTERM to kill processes that time out',
14541454default=False, action="store_true", dest="abort_on_timeout")
1455-result.add_option("--type",
1455+result.add_argument("--type",
14561456help="Type of build (simple, fips, coverage)",
14571457default=None)
1458-result.add_option("--error-reporter",
1458+result.add_argument("--error-reporter",
14591459help="use error reporter",
14601460default=True, action="store_true")
14611461return result
@@ -1634,7 +1634,7 @@ def get_pointer_compression_state(vm, context):
1634163416351635def Main():
16361636parser = BuildOptions()
1637- (options, args) = parser.parse_args()
1637+ (options, args) = parser.parse_known_args()
16381638if not ProcessOptions(options):
16391639parser.print_help()
16401640return 1