f+\ddlZddlZddlZddlZddlmZddlmZm Z m Z dZ dZ dZ Gdd ejZGd d ejZGd d ej"ZGddej"ZdZdZdZdZdZy)N) os_helper) ALL_RESOURCESRESOURCE_NAMES TestFilterzpython -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 ...] aAdditional option details: -r randomizes test execution order. You can use --randseed=int to provide an int seed value for the randomizer. The randseed value will be used to set seeds for all random usages in tests (including randomizing the tests order if -r is set). By default we always set random seed, but do not randomize test order. -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. walltime - Long running but not CPU-bound 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 c eZdZdfd ZxZS) Namespacec Fd|_d|_d|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_g|_d|_d|_d|_d|_d|_d|_ d|_!d|_"d|_#d|_$d|_%d|_&tO|di|y)NFrcoverageT))citestdirverbosequietexcludecleanupwait list_cases list_testssingle randomizefromfilefail_env_changed use_resourcestracecoverdirrunleaks huntrleaksrerunverbose3 print_slow random_seeduse_mpforeverheaderfailfast match_testspgo pgo_extendedtsan worker_jsonstarttimeoutmemlimit threshold fail_reruntempdir_add_python_optsxmlpathsuper__init__)selfkwargs __class__s //usr/lib/python3.12/test/libregrtest/cmdline.pyr5zNamespace.__init__s+        %! "  7;      ')!     $  "6")returnN)__name__ __module__ __qualname__r5 __classcell__r8s@r9r r s )#)#r:r ceZdZfdZxZS) _ArgParserc*t||dzy)Nz% Pass -h or --help for complete help.)r4error)r6messager8s r9rDz_ArgParser.errors  g HHIr:)r<r=r>rDr?r@s@r9rBrBsJJr:rBceZdZddZy) FilterActionNcjt||j}|j||jfyN)getattrdestappendconst)r6parser namespacevalue option_stringitemss r9__call__zFilterAction.__call__s' 499- eTZZ()r:rIr<r=r>rSr r:r9rGrGs*r:rGceZdZddZy)FromFileFilterActionNct||j}t|d5}|D]-}|j|j |j f/ dddy#1swYyxYw)Nzutf-8)encoding)rJrKopenrLstriprM)r6rNrOrPrQrRfplines r9rSzFromFileFilterAction.__call__s] 499- %' * 9b 9 djjlDJJ78 9 9 9 9s 3A!!A*rIrTr r:r9rVrVs9r:rVc  tdtttdtj }|j gd}|jd}|jddd d |jd d d |jdd d |jddd|jdd d |jdddd|z|jdddd|jdd d!td"#|jd$}|jd%d&d'd( |jd)d*d d+ |jd,d d-d./|jd0d1d d2 |jd3d4d d5 |jd6d7d d8d9/|jd:d d; |jd<}|jd=d>d d?|z |jd@dAdBdC|z|jdDdEd dF |jdGdHd dI|z |jdJdKdLdMtdNdOP|jdQdRdLdMtddSP|jdTdUdMtdNdVP|jdWdUdMtddXP|jdYdZd d[ |jd\d]d^d_td`|za|jdbdcddde|z|jdfdgtdhi|jdj}|jdkdld dm|z |jdndodptdq|zi|jdrdsdtdutdv#|jdwdxd dydz/|jd{d|dgtd}i|jd~ddddd|jdddtdi|jddd d |jddd d |jdd d |jdd d |jdddd d|jdd d |jddd d|jdd d |jdd d |jdddUd|jddd|jdd d |jdd d |jdddd|S)Nz regrtest.pyF)progusage descriptionepilogadd_helpformatter_class)r'z- See the section at bottom for more details.zGeneral optionsz-hz--helphelpzshow this help message and exit)actionrdz --fast-ci store_truezSlow Continuous Integration (CI) mode used by buildbot workersz --timeoutTIMEOUTzxdump the traceback and exit if a test takes more than TIMEOUT seconds; disabled if TIMEOUT is negative or equals to zero)metavarrdz--waitz:wait for user input, e.g., allow a debugger to be attachedz-Sz--startSTARTz'the name of the test at which to start.z-pz--pythonPYTHONz-Command to run Python test subprocesses with.z --randseedSEEDr"zpass a global random seed)rhrKtyperd Verbosityz-vz --verbosecountz/run tests in verbose mode with output to stdoutz-wz--rerunz#re-run failed tests in verbose modez --verbose2rzdeprecated alias to --rerun)rerKrdz-Wz --verbose3zdisplay test output on failurez-qz--quietz'no output unless one or more tests failz-oz --slowestr!zprint the slowest 10 testsz--headerz"print header with interpreter infozSelecting testsz-rz --randomizezrandomize test execution order.z-fz --fromfileFILEz'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--matchPATr'Tz2match test cases and methods with glob pattern PAT)rhrKrerMrdz-iz--ignorez3ignore test cases and methods with glob pattern PATz --matchfileFILENAMEzJsimilar to --match but get patterns from a text file, one pattern per linez --ignorefilezHsimilar to --matchfile but it receives patterns from text file to ignorez-Gz --failfastz1fail as soon as a test fails (only with -v or -W)z-uz--usez RES1,RES2,...rLz6specify which special resource intensive tests to run.)rhrerlrdz-Mz --memlimitLIMITz&run very large memory-consuming tests.z --testdirDIRzWexecute test files in the specified directory (instead of the Python stdlib test suite))rhrlrdz Special runsz-Lz --runleaksz*run the leaks(1) command just before exit.z-Rz --huntrleaks RUNCOUNTSz:search for reference leaks (needs debug build, very slow).z-jz--multiprocess PROCESSESr#zrun PROCESSES processes at oncez-Tz --coveragerz4turn on code coverage tracing using the trace modulez-Dz --coverdirz&directory where coverage files are putz-Nz --nocoverdir store_constrz$put coverage files alongside modules)rerMrKrdz-tz --threshold 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--pgor(z1enable Profile Guided Optimization (PGO) training)rKrerdz--pgo-extendedz.enable extended PGO training (slower training)z--tsanr*zif a test file alters the environment, mark the test as failedz --fail-rerunzFif a test failed and then passed when re-run, mark the tests as failedz --junit-xmlr3z4writes JUnit-style XML results to the specified file)rKrhrdz --tempdirPATHz/override the working directory for the test runz --cleanupz$remove old test_python_* directoriesz--bisectz/if some tests fail, run test.bisect_cmd on themz--dont-add-python-optsr2 store_falsezinternal option, don't use it)rBUSAGE DESCRIPTIONEPILOGargparseRawDescriptionHelpFormatter set_defaultsadd_argument_group add_argumentintrGrVresources_listrelative_filenamer)rN more_detailsgroups r9_create_parserrs]#$/%!&(0(L(L NF  B'CL  % %&7 8E tXf=? {<-. {</0 {I=> x -. tYE()* tZKM |V)79  % %k 2E t[MO tY|AC |Lw9; t\,<> tY|EG t[L8: z,@B  % %&7 8E t]<= LN t\6E()* t[>@ tZ A()* tY),dPR tZ),eQS }j)2$>?  ~z)2%78  t\,OQ tWo&^&(456 t\7D()* {E-HI  % %n 5E t\,H()* t^[&*,89: t-{$3=? t\,#%& t\5-DF t^+4jBD t]K>@ t]<EG t[>? ~l12 ~l56 tW5OQ ' LN xf\Z\ +L12 ~l78 }9j#$ {FMO {<BD z,MO /6H+;= Mr:c^tjjtj|SrI)ospathjoinrSAVEDCWD)strings r9rrjs 77<< **F 33r:c|jd}t|dvrtjd|drt |dnd}|drt |dnd}t|dkDr |dr|dnd }|||fS) N:)z&needs 2 or 3 colon-separated argumentsrrrz reflog.txt)splitlenr}ArgumentTypeErrorr)rargsnwarmupntrackedfnames r9rrps << D 4y(( 46 6"1gc$q'l1G#Aws47|AH4y1}aDGlE He ##r:c|jdDcgc]}|j}}|D]:}|dk(s|dk(r|ddk(r|dd}|tvs$tjd|z|Scc}w)N,allnoner-rzinvalid resource: )rlowerrr}r)rxurs r9rr{s"LL-.q.A. G :f  Q43;!"A N ",,-AA-EF F G H /sA.c t}|jD],\}}t||std|zt |||.|j g|_t }|j||d|_|jD](}|jds|jd|z*|j2|jdk7r t|j|_ nd|_ |js |jrJ|j d|_d |_d |_d |_|j(d |_d |_d |_nd |_|jrD|j2g|_|j2j5dd g|jXd |_ nP|jrD|j2g|_|j2j5dd d g|jd|_ |j6r|j8r|jd|j |j:r|jd|j(A|j |jdt=j>|j(|_|j@r)|jBs|j.s|jd|jDr5|jBs|j*s |j.r|jd|jFrd |_"|jHrtKdtLjN|jPrd|_!|j|jdkrd|_ |j2r|j2D]}|D]}|d k(rtR|j dd|dk(r|j dd=1d } |ddk(rd } |dd}| r+||j vsS|j jU|o||j vs~|j jW||jXd |_|jBrd |_-|j\r:|j.r.|j "d |_tKdtLjN|j\r.|j^r"d|_/tKdtLjN|j`rd |_ |j\rM|j\\} } } | dks| dkr3d} tK| tLjNd tMjbd|S#t$r"|jd|jYwxYw)Nz3%r is an invalid keyword argument for this function)rrOrrzunrecognized arguments: %szinvalid timeout value: rTFriz-cpuiXz-s and -f don't go together!z-T and -j don't go together!z-p requires -j!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.)filerzZWARNING: Disable --verbose3 because it's incompatible with --huntrleaks without -jN optionzHWARNING: Disable --junit-xml because it's incompatible with --huntrleakszwInvalid values for the --huntrleaks/-R parameters. The number of warmups and repetitions must be at least 1 each (1:1).)rflushr)2r rRhasattr TypeErrorsetattrrrparse_known_argsr startswithrDr-float ValueErrorslow_cifast_cir#rrr0pythonrr!r r2useinsertrrrshlexrr&rr(r) nowindowsprintsysstderrrrremoverLr"r%rr3r$exit)rr7nskvrNargarrwarmup repetitions_msgs r9 _parse_argsrs B 1r1~02345 5Aq     F%%42%>qABGww= >>#  LL5; <= zz ::  G"2::. BJ zzRZZ 99 BI " 99 BH  # zz 66>BF  a%! :: BJ  66>BF  a%) :: BJ yyR[[ 34 yy 34 yy 99  LL* +KK *  {{BJJ"++ :; vv2::R[[ 23  || 9?Bzz K xx  zz ::?BJ vv /A /:*7B$$Q';((+Q43;!F!"AB,,,((//2b...$$++A. / /" ~~!  zz  }}):  0::  }}  "::  zz  }}!# Q A:q!C #CJJd 3 HHQK Iu G 6rzznEF GsU'U=<U=)r}os.pathrrr test.supportrutilsrrrrzr{r|r ArgumentParserrBActionrGrVrrrrrr r:r9rs "<<   j Z*#""*#ZJ((J *8??* 98??9^B4 $  Sr: