U \k^G@szddlZddlZddlZddlmZdZdZdZdZedZ Gdd d ej Z d d Z d d Z ddZddZddZdS)N)supportzpython -m test [options] [test_name1 [test_name2 ...]] python path/to/Lib/test/regrtest.py [options] [test_name1 [test_name2 ...]] a`Run Python regression tests. If no arguments or options are provided, finds all files matching the pattern "test_*" in the Lib/test subdirectory and runs them in alphabetical order (but see -M and -u, below, for exceptions). For more rigorous testing, it is useful to use the following command line: python -E -Wd -m test [options] [test_name1 ...] a,Additional option details: -r randomizes test execution order. You can use --randseed=int to provide an int seed value for the randomizer; this is useful for reproducing troublesome test orders. -s On the first invocation of regrtest using -s, the first test file found or the first test file given on the command line is run, and the name of the next test is recorded in a file named pynexttest. If run from the Python build directory, pynexttest is located in the 'build' subdirectory, otherwise it is located in tempfile.gettempdir(). On subsequent runs, the test in pynexttest is run, and the next test is written to pynexttest. When the last test has been run, pynexttest is deleted. In this way it is possible to single step through the test files. This is useful when doing memory analysis on the Python interpreter, which process tends to consume too many resources to run the full regression test non-stop. -S is used to continue running tests after an aborted run. It will maintain the order a standard run (ie, this assumes -r is not used). This is useful after the tests have prematurely stopped for some external reason and you want to start running from where you left off rather than starting from the beginning. -f reads the names of tests from the file given as f's argument, one or more test names per line. Whitespace is ignored. Blank lines and lines beginning with '#' are ignored. This is especially useful for whittling down failures involving interactions among tests. -L causes the leaks(1) command to be run just before exit if it exists. leaks(1) is available on Mac OS X and presumably on some other FreeBSD-derived systems. -R runs each test several times and examines sys.gettotalrefcount() to see if the test appears to be leaking references. The argument should be of the form stab:run:fname where 'stab' is the number of times the test is run to let gettotalrefcount settle down, 'run' is the number of times further it is run and 'fname' is the name of the file the reports are written to. These parameters all have defaults (5, 4 and "reflog.txt" respectively), and the minimal invocation is '-R :'. -M runs tests that require an exorbitant amount of memory. These tests typically try to ascertain containers keep working when containing more than 2 billion objects, which only works on 64-bit systems. There are also some tests that try to exhaust the address space of the process, which only makes sense on 32-bit systems with at least 2Gb of memory. The passed-in memlimit, which is a string in the form of '2.5Gb', determines how much memory the tests will limit themselves to (but they may go slightly over.) The number shouldn't be more memory than the machine has (including swap memory). You should also keep in mind that swap memory is generally much, much slower than RAM, and setting memlimit to all available RAM or higher will heavily tax the machine. On the other hand, it is no use running these tests with a limit of less than 2.5Gb, and many require more than 20Gb. Tests that expect to use more than memlimit memory will be skipped. The big-memory tests generally run very, very long. -u is used to specify which special resource intensive tests to run, such as those requiring large file support or network connectivity. The argument is a comma-separated list of words indicating the resources to test. Currently only the following are defined: all - Enable all special resources. none - Disable all special resources (this is the default). audio - Tests that use the audio device. (There are known cases of broken audio drivers that can crash Python or even the Linux kernel.) curses - Tests that use curses and will modify the terminal's state and output modes. largefile - It is okay to run some test that may create huge files. These tests can take a long time and may consume >2 GiB of disk space temporarily. network - It is okay to run tests that use external network resource, e.g. testing SSL support for sockets. decimal - Test the decimal module against a large suite that verifies compliance with standards. cpu - Used for certain CPU-heavy tests. subprocess Run all tests for the subprocess module. urlfetch - It is okay to download files required on testing. gui - Run tests that require a running GUI. tzdata - Run tests that require timezone data. To enable all resources except one, use '-uall,-'. For example, to run all the tests except for the gui tests, give the option '-uall,-gui'. --matchfile filters tests using a text file, one pattern per line. Pattern examples: - test method: test_stat_attributes - test class: FileTests - test identifier: test_os.FileTests.test_stat_attributes ) ZaudioZcursesZ largefileZnetworkZdecimalZcpu subprocessZurlfetchZgui)ZextralargefileZtzdatacseZdZfddZZS) _ArgParsercst|ddS)Nz% Pass -h or --help for complete help.)supererror)selfmessage __class__./usr/lib/python3.8/test/libregrtest/cmdline.pyrsz_ArgParser.error)__name__ __module__ __qualname__r __classcell__r r r r rsrcCsDtdtttdtjd}d}|d}|jdddd d |jd d td d|jdddd |jddd|jdddd|d|d}|jddddd |jdd dd!d |jd"d#dd$d |jd%d&dd'd |jd(d)dd*d+d,|jd-dd.d |d/}|jd0d1dd2|d |jd3d4d5t d6d7|jd8d9d:d;|d|jdd |jd?d@ddA|d |jdBdCdDdEdFdGdH|jdIdJdKdLdM|jdNdOddPd |jdQdRdSdFt dT|dU|jdVdWdXdY|d|jdZd[t d\d|d]}|jd^d_d`dadbdcdd|jdedfddg|d |jdhdidjt dk|d|jdldmdndot dpd7|jdqdrddsdtd,|jdudvd[t dwd|jdxdyd`ddzd{d||jd}d~dt dd|jddddd |jddddd |jdddd |jdddd |jdddddd|jdddd |jdddd |jdddJdd|jdddd|jdddd |S)Nz regrtest.pyF)progZusageZ descriptionZepilogZadd_helpZformatter_classz- See the section at bottom for more details.zGeneral optionsz-hz--helphelpzshow this help message and exit)actionrz --timeoutZTIMEOUTzxdump the traceback and exit if a test takes more than TIMEOUT seconds; disabled if TIMEOUT is negative or equals to zero)metavartyperz--wait store_truez:wait for user input, e.g., allow a debugger to be attachedz --worker-argsZARGS)rz-Sz--startZSTARTz'the name of the test at which to start.)rrZ Verbosityz-vz --verbosecountz/run tests in verbose mode with output to stdoutz-wz --verbose2z#re-run failed tests in verbose modez-Wz --verbose3zdisplay test output on failurez-qz--quietz'no output unless one or more tests failz-oz --slowest print_slowzprint the slowest 10 tests)rdestrz--headerz"print header with interpreter infozSelecting testsz-rz --randomizezrandomize test execution order.z --randseedZSEED random_seedz5pass a random seed to reproduce a previous random run)rrrrz-fz --fromfileZFILEz'read names of tests to run from a file.z-xz --excludez arguments are tests to *exclude*z-sz--singlez#single step through a set of tests.z-mz--matchZPAT match_testsappendz2match test cases and methods with glob pattern PAT)rrrrz --matchfileZFILENAMEmatch_filenamezJsimilar to --match but get patterns from a text file, one pattern per line)rrrz-Gz --failfastz1fail as soon as a test fails (only with -v or -W)z-uz--usez RES1,RES2,...z6specify which special resource intensive tests to run.)rrrrz-Mz --memlimitZLIMITz&run very large memory-consuming tests.z --testdirZDIRzWexecute test files in the specified directory (instead of the Python stdlib test suite)z Special runsz-lz --findleaksZ store_constz&deprecated alias to --fail-env-changed)rconstdefaultrz-Lz --runleaksz*run the leaks(1) command just before exit.z-Rz --huntrleaksZ RUNCOUNTSz:search for reference leaks (needs debug build, very slow).z-jz--multiprocessZ PROCESSESuse_mpzrun PROCESSES processes at oncez-Tz --coveragetracez4turn on code coverage tracing using the trace modulez-Dz --coverdirz&directory where coverage files are putz-Nz --nocoverdircoverdirz$put coverage files alongside modules)rr rrz-tz --thresholdZ THRESHOLDz call gc.set_threshold(THRESHOLD)z-nz --nowindowsz'suppress error message boxes on Windowsz-Fz --foreverzKrun the specified tests in a loop, until an error happens; imply --failfastz --list-testszAonly write the name of tests that will be run, don't execute themz --list-caseszGonly write the name of test cases that will be run , don't execute themz-Pz--pgopgoz1enable Profile Guided Optimization (PGO) training)rrrz--pgo-extendedz.enable extended PGO training (slower training)z--fail-env-changedz>if a test file alters the environment, mark the test as failedz --junit-xmlZxmlpathz4writes JUnit-style XML results to the specified file)rrrz --tempdirPATHz/override the working directory for the test runz --cleanupz$remove old test_python_* directories) rUSAGE DESCRIPTIONEPILOGargparseZRawDescriptionHelpFormatterZadd_argument_group add_argumentfloatintresources_listrelative_filename huntrleaks)parserZ more_detailsgroupr r r _create_parsersF                                r3cCstjtj|S)N)ospathjoinrZSAVEDCWD)stringr r r r/sr/cCsz|d}t|dkr td|dr4t|dnd}|drLt|dnd}t|dkrl|drl|dnd }|||fS) N:)rz&needs 2 or 3 colon-separated argumentsrrrz reflog.txt)splitlenr*ArgumentTypeErrorr-)r7argsZnwarmupZntrackedZfnamer r r r0"s   r0cCsbdd|dD}|D]D}|dks|dkr.q|ddkrF|dd}|tkrtd |q|S) NcSsg|] }|qSr )lower).0xr r r .sz"resources_list..,allnoner-rzinvalid resource: )r<RESOURCE_NAMESr*r>)r7urr r r r.-s  r.c Ks$tjdddddddddddddddddddddddd}|D]*\}}t||s^td|t|||q@|jdkr|g|_t}|j||dd|_ |j D]&}| dr| d |t dq|jdkrd |_|jr|jr| d |jdk r|jr| d |jr*|js*|js*| d |jrT|jsJ|jsJ|jrT| d|jrbd |_|jrxtdt jd|jrd|_|jdk r|jdkrd|_|jdk r|jdkrdt pd|_|j!r|j!D]}|D]}|dkrt"|jdd<q|dkr |jdd=qd} |ddkrBd } |dd}| rb||jkrz|j#|n||jkr|j$|qq|j%dk rd |_&|jrd |_'|j(r|jrd|_tdt jd|j)r|j*dkrg|_*t+|j)"} | D]} |j*$| ,qW5QRX|j-r d |_|S)NrFrZcoverage)ZtestdirverbosequietZexcludesingle randomizefromfile findleaks use_resourcesr#r$Zrunleaksr0verbose2rrr"verbose3foreverheaderfailfastrr%z3%r is an invalid keyword argument for this function)r? namespacerGzunrecognized arguments: %sTz-s and -f don't go together!z-T and -j don't go together!z#-G/--failfast needs either -v or -Wz--pgo/-v don't go together!z\Warning: the --nowindows (-n) option is deprecated. Use -vv to display assertions in stderr.)filerrErFznWARNING: Disable --verbose3 because it's incompatible with --huntrleaks: see http://bugs.python.org/issue27103).r*Z Namespaceitemshasattr TypeErrorsetattrrQr3Zparse_known_argsr? startswithrsysexitrPZfail_env_changedrMrOr"r#rVrKrSr%rRZ pgo_extendedZ nowindowsprintstderrrLZtimeoutr4 cpu_countZuse ALL_RESOURCESremoverrrNrUr0rropenstriprT) r?kwargsnskvr1argarJrdfpliner r r _parse_args9s                           ro)r*r4r^Ztestrr'r(r)rcrHArgumentParserrr3r/r0r.ror r r r s  i