����JFIF���������
1#@!#!123s
D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
usr
/
lib
/
python3.10
/
test
/
libregrtest
/
__pycache__
/
Filename :
main.cpython-310.pyc
back
Copy
o �����*�g�d����������������������@���s��d�dl�Z�d�dlZd�dlZd�dlZd�dlZd�dlZd�dlZd�dlZd�dlZd�dl Z d�dl Z d�dlmZ�d�dl mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ�d�dlmZ�d�dlm Z �d�dl!m"Z"m#Z#m$Z$m%Z%�d�dl&m'Z'�d�dl(m)Z)�d Z*G�d d��d�Z+ddd �Z,dS�)�����N)�_parse_args)� findtests�runtest�get_abs_module� is_failed�STDTESTS�NOTTESTS�PROGRESS_MIN_TIME�Passed�Failed� EnvChanged�Skipped�ResourceDenied�Interrupted� ChildError� DidNotRun)�setup_tests)�setup_pgo_tests)�removepy�count�format_duration� printlist)�support)� os_helperg������^@c�������������������@���s����e�Zd�ZdZdd��Zdd��Zd7dd�Zd8d d�Zdd ��Zdd��Z dd��Z dd��Zdd��Zdd��Z dd��Zdd��Zdd��Zdd��Zd d!��Zd"d#��Zd$d%��Zd&d'��Zd(d)��Zd*d+��Zd,d-��Zd.d/��Zd9d1d2�Zd3d4��Zd5d6��Zd0S�):�Regrtestal��Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, exclude, single, randomize, findleaks, use_resources, trace, coverdir, print_slow, and random_seed) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. c�����������������C���s����d�|�_�g�|�_g�|�_g�|�_g�|�_g�|�_g�|�_g�|�_g�|�_g�|�_ g�|�_ d�|�_d|�_g�|�_ d�|�_t���|�_d|�_d|�_d�|�_d�|�_d�|�_d�|�_d�|�_d�|�_d�S�)NF������)�ns�tests�selected�good�bad�skipped�resource_denieds�environment_changed�run_no_tests� need_rerun�rerun�first_result�interrupted� test_times�tracer�time� monotonic� start_time� test_count�test_count_width�next_single_test�next_single_filename� testsuite_xml�win_load_tracker�tmp_dir�worker_test_name��self��r9����,/usr/lib/python3.10/test/libregrtest/main.py�__init__6���s0��� zRegrtest.__init__c�����������������C���s<���t�|�j�t�|�j�B�t�|�j�B�t�|�j�B�t�|�j�B�t�|�j�B�S��N)�setr ���r!���r"���r#���r$���r%���r7���r9���r9���r:����get_executeda���s������zRegrtest.get_executedFc�������������� ���C���sv��|j�}t|ttf�s|s|�j�|j|f��t|t�r!|�j�|��nYt|t �r3|�j �|��|�j�|��nGt|t�r?|�j �|��n;t|t �rK|�j�|��n/t|t�r_|s^|�j�|��|�j�|��nt|t�rk|�j�|��nt|t�rtd|�_ntd|���|r�t|ttf�s�|�j�|��|j}|r�dd�lm��m}�|D�]}z|�j�|�|���W�q��|jy����t|tj d����w�d�S�d�S�)NTzinvalid test result: %rr�����file)!�name� isinstancer���r���r*����append�duration_secr ���r ���r���r"���r#���r ���r���r$���r���r!���r&���r���r%���r)���� ValueError�remove�xml_data�xml.etree.ElementTree�etree�ElementTreer3���� fromstring� ParseError�print�sys� __stderr__)r8����resultr'���� test_namerG����ET�er9���r9���r:����accumulate_resultf���sH��� � ��zRegrtest.accumulate_resultr���c�����������������C���s����|�}|�����}|d�urd|d�d|���}t���|�j�}tt|�d�\}}t|d�\}}d|||f�}|��d|���}|rA|d�d��}t|dd��d�S�) Nz load avg: z.2f� �<���z%d:%02d:%02d���T)�flush)� getloadavgr,���r-���r.����divmod�intrM���)r8����line�empty�load_avg� test_time�mins�secs�hoursr9���r9���r:����log����s���zRegrtest.logc�����������������C���sh���|�j�jrd�S�||�j���|�j���}t|�j�t|�j��}|r'|�j�js'|��d|���}|��d|��d|�����d�S�)N�/�[z] ) r����quietr0���r/����lenr!���r$����pgorc���)r8���� test_index�textr\����failsr9���r9���r:����display_progress����s���zRegrtest.display_progressc����������� ������C���s����t�tjdd���fi�|��}|jrg��t_|�_|j}|d�ur0ddlm }�||j�\}}||_||�_ t|j��|j rU|j \}}}|dk�sF|dk�rUd} t| tjdd��t�d��|jr`tj�|j�|_||�_d�S�)Nr���r���)�parse_worker_argszwInvalid values for the --huntrleaks/-R parameters. The number of warmups and repetitions must be at least 1 each (1:1).T�r@���rX�������)r���rN����argv�xmlpathr����junit_xml_listr3����worker_args�test.libregrtest.runtest_mprm���r6���r����args� huntrleaksrM����stderr�exit�tempdir�os�path� expanduserr���) r8����kwargsr���rs���rm���rQ����warmup�repetitions�_�msgr9���r9���r:���� parse_args����s&��� zRegrtest.parse_argsc�����������������C���s���||�_�|�jjr<tj�|�jd�|�_z"t|�jd��}|� ��� ��}|g|�_�W�d�����n1�s,w���Y��W�n �ty;���Y�nw�|�jjr�g�|�_�t �d�}ttj�tj|�jj���*}|D�]}|�dd�d�}|� ��}|�|�}|d�urv|�j��|�����qWW�d�����n1�s�w���Y��t|�j���|�jjr�t|�j��td�d���}t���}|�jjr�|�jjD�]} | |v�r�|�| ��|�| ��q�g�|�j_|�jjr�t |�jjt!��t"���} nt |�jj||�} |�jjs�|�j�p�|�jjp�| |�_#n|�j�|�_#|�jj�r|�j#d�d��|�_#z| �$|�j#d��}| |d��|�_%W�n �t&�y ���Y�nw�|�jj'�r7z|�j#d�|�j#�$|�jj'��=�W�n�t(�y6���t)d|�jj'�t*j+d��Y�nw�|�jj,�rY|�jj-d�u��rJt.�/d �|�j_-t.�0|�jj-��t.�1|�j#��d�S�d�S�) N� pynexttest�rz\btest_[a-zA-Z0-9_]+\b�#r���r���z1Couldn't find starting test (%s), using all testsr?���i����)2r���r����singlerz���r{����joinr5���r2����open�read�strip�OSError�fromfile�re�compiler����SAVEDCWD�split�searchrC����groupr���rh���r���r���r����copy�excluderu���rF����add�testdirr����listr=���r����indexr1���� IndexError�startrE���rM���rN���rw���� randomize�random_seed�random� randrange�seed�shuffle)r8���r����fp� next_test�regexr\����match�stdtests�nottests�arg�alltests�posr9���r9���r:���� find_tests����s���� ��� ��� � � �� �zRegrtest.find_testsc�����������������C���s���|�j�D�]}t|��qd�S�r<���)r���rM���)r8���rA���r9���r9���r:���� list_tests��s��� �zRegrtest.list_testsc�����������������C���sX���|D�]'}t�|tjj�rqt�|tj�r|��|��qt�|tj�r)t�|�r)t |� ����qd�S�r<���)rB����unittest�loader�_FailedTest� TestSuite�_list_cases�TestCaser���� match_testrM����id)r8����suite�testr9���r9���r:���r������s��� ��zRegrtest._list_casesc�������������� ���C���s����dt�_t��|�jj|�jj��|�jD�]%}t|�j|�}z tj � |�}|��|��W�q�tjy5���|�j �|��Y�qw�|�j rWttjd��ttt|�j �d�dtjd��t|�j tjd��d�S�d�S�)NFr?���r�����skipped:)r����verbose�set_match_testsr����match_tests�ignore_testsr���r���r�����defaultTestLoader�loadTestsFromNamer�����SkipTestr"���rC���rM���rN���rw���r���rg���r���)r8���rQ����abstestr����r9���r9���r:���� list_cases"��s��� ��zRegrtest.list_casesc����������� ������C���s|��d|�j�_d|�j�_d|�j�_|����|�_|�����|��d��t|�j�}|�j� ���|D�]~}|j }|�j�|��|j p5g�}|jp:g�}dd��|D��}dd��|D��}d|�j�_|�j�j}|sU|r�|�j�jd�u�r_g�|�j�_|�j�j�|��|�j�j�|��dd�|�j�j��} |��d |��d | ��d���n |��d |��d���t|�j�|�}||�j�_|�j|dd ��t|t�r��nq&|�jr�ttt|�j�d�d��t|�j��|�����d�S�)NTFz'Re-running failed tests in verbose modec�����������������S�������g�|�]^}}|��d��d��qS��rU���r����r������.0�test_full_namer����r9���r9���r:���� <listcomp>D�������z/Regrtest.rerun_failed_tests.<locals>.<listcomp>c�����������������S���r����r����r����r����r9���r9���r:���r����E��r����z matching: �, zRe-running z in verbose mode (�)z in verbose mode)r'���r����z failed again:)r���r�����failfast�verbose3�get_tests_resultr(���rc���r����r&����clearrA���r'���rC����errors�failuresr�����extendr����r���rT���rB���r���r!���rM���r���rg���r����display_result) r8���� rerun_listrP���rQ���r����r�����error_names� failure_names�orig_match_tests�matchingr9���r9���r:����rerun_failed_tests3��sF��� � zRegrtest.rerun_failed_testsc�����������������C���s���|�j�jrd�S�t���td|�������|�jrtd��t|�j�|�����}|r4t���ttt |�d�d��t |��|�jr_|�j�js_t���|�j sT|�jsT|�jsTt |�j�dkrTtddd��ttt |�j�d�d ��|�j�jr�|�jjd d��t���td��|�jd�d ��D�]\}}td|t|�f���qx|�j r�t���ttt |�j �d�d��t |�j ��|�jr�t���td�tt |�j�d����t |�j��|�jr�|�j�js�t���ttt |�j�d�d��t |�j��|�jr�t���tdtt |�j�d����t |�j��|�jr�t���ttt |�j�d�d��t |�j��d�S�d�S�)Nz== Tests result: %s ==z(Test suite interrupted by signal SIGINT.r����zomitted:r����AllrU���)�endzOK.T)�reversez10 slowest tests:� ���z- %s: %szfailed:z%{} altered the execution environment:r����z%s:zre-run testz run no tests:)r���rh���rM���r����r)���r=���r���r>���r���rg���r���r ���rf���r!���r"���� print_slowr*����sortr���r$����formatr'���r%���)r8����omittedr_���r����r9���r9���r:���r����_��sd����� � �zRegrtest.display_resultc�����������������C���s���|�j�jrdd�l}|jddd�|�_tj���}d}|�j�jr%|dt|�j�j��7�}|�� |��d�}t |�jd�D�]�\}}t� ��}|}|rDd||f�}|��||��|�jrcd } tt���} |�jj| t��| d ��| d�}nt|�j�|�}|��|��t|t�ru�nAt|�}t� ��|�}|tkr�d|t|�f�}nt|t�r�d�}tj���D�]} | |vr�| �d �r�t�| ��q�|�j�jr�t||�j��r��nq2|r�t|��d�S�d�S�)Nr���FT)�tracer���zRun tests sequentiallyz (timeout: %s)r���z%s -- %szDresult = runtest(self.ns, test_name); self.accumulate_result(result))�globals�localsrP���z%s in %sztest.) r���r�����Tracer+���rN����modules�keys�timeoutr���rc���� enumerater���r,���r-���rl����dictr�����runctxr����r���rT���rB���r����strr ���r ���� startswithr����unloadr����r���rM���)r8���r�����save_modulesr����� previous_testri���rQ���r.���rj����cmdr���rP���r_����moduler9���r9���r:����run_tests_sequential���sP��� ���zRegrtest.run_tests_sequentialc�����������������c���s6����� �|D�]}|V��|�j�r�d�S�|�jjr|�jr�d�S�qqr<���)r!���r����fail_env_changedr$���)r8���r���rQ���r9���r9���r:���� _test_forever���s������zRegrtest._test_foreverc�����������������C���sx���t�dt���gtj����R����t�dtjdd�dtj���t�dt�����t� ��}|r-t�d|��t�dt �d�t���f���d�S�) Nz==T)�aliasedz %s-endianz== cwd:z == CPU count:z== encodings: locale=%s, FS=%sF) rM����platform�python_implementationrN����versionr����� byteorderrz����getcwd� cpu_count�locale�getpreferredencoding�getfilesystemencoding)r8���r����r9���r9���r:����display_header���s���� � �zRegrtest.display_headerc�����������������C���s����g�}|�j�r|�d��n |�jjr|�jr|�d��nt|�j|�j�|�j|�j|�jf�s+|�d��|�jr3|�d��|s:|�d��d� |�}|�j rId|�j |f�}|S�)N�FAILUREzENV CHANGEDzNO TEST RUN�INTERRUPTED�SUCCESSr����z %s then %s)r!���rC���r���r����r$����anyr ���r"���r)���r����r(���)r8���rP���r9���r9���r:���r�������s"���� zRegrtest.get_tests_resultc�������������� ���C���s���|�j�js|�j�js|�j�js|�j�js|�js|�j�js|�����|�j�jr4|�j�j\}}}|dk�r4d}t |t jdd��|�j�jr?t d|�j�j ��|�j�jrS|��t|�j��|�_d|�_d|�_nt|�j�|�_d�t|�j��|�_t|�j�d�|�_|�j�jr�d d lm}�t jdkr�|�jd�u�r�d dlm}�z|��|�_W�n�ty��}�z t d |�����W�Y�d�}~nd�}~ww�z||���W�|�jd�ur�|�j� ���d�|�_d�S�d�S�|�jd�ur�|�j� ���d�|�_w�|��!���d�S�)N����zhWARNING: Running tests with --huntrleaks/-R and less than 3 warmup repetitions can give false positives!Trn���zUsing random seedr���z/{}r���r���)�run_tests_multiprocess�win32)�WindowsLoadTrackerz%Failed to create WindowsLoadTracker: )"r����headerrh���rf���r����r���ru���r����rv���rM���rN����stdoutr����r�����foreverr����r����r���r/���r0����iterr����rg����use_mprt���r��r����r6����test.libregrtest.win_utilsr��r4����PermissionError�closer����)r8���r~���r���r����r����r��r���errorr9���r9���r:���� run_tests���sZ���������� � zRegrtest.run_testsc�����������������C���s����|�j�r+|�jr%t|�j�d��}|�|�jd���W�d�����n1�sw���Y��nt�|�j���|�jr=|�j���}|jdd|�j j d��t���t� ��|�j�}tdt|����td|�������|�j jrft�dt������d�S�d�S�)N�w� T)�show_missing�summary�coverdirzTotal duration: %szTests result: %szleaks %d)r2���r1���r�����writerz����unlinkr+����results� write_resultsr���r��rM���r,���r-���r.���r���r�����runleaks�system�getpid)r8���r����r�����durationr9���r9���r:����finalize-��s&����� ��zRegrtest.finalizec����������� ��� ���C���s��|�j�js |�js d�S�dd�lm��m}�|�d�}dddd�}|�jD�]%}|�|��|D�]}z||��t|� |d��7��<�W�q)�t yD���Y�q)w�q |���D�]\}}|�|t |���qJtj�tj|�j�j�}t|d��}|�|�D�]} |�| ��qlW�d�����d�S�1�sw���Y��d�S�)Nr���� testsuites)r���r����r�����wb)r���rq���r3���rH���rI���rJ����ElementrC���r[����getrE����itemsr=���r����rz���r{���r����r���r����r�����tostringlistr��) r8���rR����root�totalsr�����k�vrq����f�sr9���r9���r:����save_xml_resultB��s,��� ���"�zRegrtest.save_xml_resultc�����������������C���st���|�j�jr |�j�j|�_|�js0t���r+t�d�|�_|�jd�u�r!t�d�|�_tj�|�jd�|�_nt � ��|�_tj�|�j�|�_d�S�)N�abs_builddir�srcdir�build)r���ry���r5���� sysconfig�is_python_build�get_config_varrz���r{���r�����tempfile� gettempdir�abspathr7���r9���r9���r:����set_temp_dir[��s��� zRegrtest.set_temp_dirc�����������������C���sV���t�j|�jdd��t����}|�jd�urd�|�}nd�|�}|tj7�}t�j� |�j|�}|S�)NT)�exist_okztest_python_worker_{}ztest_python_{}) rz����makedirsr5���r��r6���r����r����FS_NONASCIIr{���r����)r8����pid�test_cwdr9���r9���r:����create_temp_dirq��s��� zRegrtest.create_temp_dirc�����������������C���sz���dd�l�}tj�|�|�j�d�}td|�j���|��|�D�]}tj�|�r/td|���t� |��qtd|���t� |��qd�S�)Nr���z test_python_*zCleanup %s directoryzRemove directory: %szRemove file: %s)�globrz���r{���r�����escaper5���rM����isdirr����rmtreer��)r8���r<��r{���rA���r9���r9���r:����cleanup���s����zRegrtest.cleanupNc�������������� ���K���s����|���|��|�����|�jjr|�����t�d��|����}z&tj|dd���||�j_ |�� ||��W�d�����W�d�S�1�s9w���Y��W�d�S��ty`�}�ztj tdd��t�|j��W�Y�d�}~d�S�d�}~ww�)Nr���T)rf���)rx���)r����r5��r���r@��rN���rx���r;��r����temp_cwdry����_main� SystemExit�faulthandler�dump_traceback_later�EXIT_TIMEOUT�code)r8���r���r}���r:���excr9���r9���r:����main���s ��� &���z Regrtest.mainc�����������������C���s.���|�j�d�ur |�j����S�ttd�rt���d�S�d�S�)NrY���r���)r4���rY����hasattrrz���r7���r9���r9���r:���rY������s ��� zRegrtest.getloadavgc�����������������C���s��|�j�d�urddlm}�||�j|�j���|�jjrtd��|�jjt_|�jj t_ t|�j��|��|��|�jj r;|�� ���t�d��|�jjrH|�����t�d��|�����|�����|�jjr[|�jr[|�����|�����|�����|�jrkt�d��|�jrst�d��|�jjr|�jrt�d��t�d��d�S�)Nr���)�run_tests_workerzPress any key to continue...ro�������r��)r6���rt���rK��r����wait�inputrh���r����PGO�pgo_extended�PGO_EXTENDEDr���r����r����rN���rx���r����r��r�����verbose2r!���r����r��r+��r)���r����r$���)r8���r���r}���rK��r9���r9���r:���rB�����s8��� zRegrtest._main)F)r���r<���)�__name__� __module__�__qualname__�__doc__r;���r>���rT���rc���rl���r����r����r����r����r����r����r����r����r����r����r����r��r��r+��r5��r;��r@��rI��rY���rB��r9���r9���r9���r:���r������s6����+ 'I ,;7 1 r���c�����������������K���s���t���jdd|�i|���dS�)zRun the Python suite.r���Nr9���)r���rI��)r���r}���r9���r9���r:���rI�����s���rI��r<���)-rD��r����rz���r����r����r����rN���r/��r2��r,���r�����test.libregrtest.cmdliner����test.libregrtest.runtestr���r���r���r���r���r���r ���r ���r���r���r ���r���r���r���r����test.libregrtest.setupr����test.libregrtest.pgor����test.libregrtest.utilsr���r���r���r���r����r����test.supportr���rF��r���rI��r9���r9���r9���r:����<module>���s4����D�����D