
    8bh)              	       N   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlm	Z	 d dl
mZ ddlmZ ddlmZmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZmZmZmZ dZ d Z!d Z"d Z#dededdfdZ$g Z%dededdfdZ&	 ddedede'ddfdZ(dededdfdZ)dededefdZ*y)    N)support)threading_helper   )
match_test)State
TestResult	TestStats)RunTests)saved_test_environment)setup_tests)get_test_runner)TestNameclear_cachesremove_testfnabs_module_nameprint_warningg      >@c                    t        j                         }|j                  |       }|j                  D ]  }t	        |t
        j                          |j                  rt        d      t        |t               t        |      S )N)filezerrors while loading tests)unittest
TestLoaderloadTestsFromModuleerrorsprintsysstderr	Exception_filter_suiter   
_run_suite)test_modloadertestserrors       A/opt/python-3.12.12/usr/lib/python3.12/test/libregrtest/single.pyrun_unittestr$      sd      "F&&x0Ee#**% }}455%$e    c                     	 g }| j                   D ]T  }t        |t        j                        rt	        ||       |j                  |       ; ||      sD|j                  |       V || _         y N)_tests
isinstancer   	TestSuiter   append)suiteprednewteststests       r#   r   r   '   sZ    HHdH../$%OOD!Dz%  ELr%   c                    	 t        t        j                  t        j                  t        j
                  d u      }|j                  |       }t        j
                  Xdd lmc m	} |j                         }|j                  |      j                  d      }t        j
                  j                  |       |j                  s(|j                  s|j                   st        j"                  |j%                         st'        j(                  |      }t+        |j                         dk(  r|j,                  s|j                   d   d   }nNt+        |j,                        dk(  r|j                   s|j,                  d   d   }nd}t        j                  s|dz  }|j                   D 	cg c]  \  }}	t/        |      |	f }
}}	|j,                  D 	cg c]  \  }}	t/        |      |	f }}}	t        j0                  ||
||      |S c c}	}w c c}	}w )N)	verbositycapture_outputr   asciir   zmultiple errors occurredz!; run in verbose mode for details)stats)r   r   stdoutr   verbosejunit_xml_listrunxml.etree.ElementTreeetreeElementTreeget_xml_elementtostringdecoder+   testsRunskippedr   TestDidNotRunwasSuccessfulr	   from_unittestlenfailuresstrTestFailedWithDetails)r,   runnerresultETxml_elemxml_strr4   errtcexc_strr   rE   s               r#   r   r   3   s   <SZZ'.-4-C-C4-ORF ZZF)**))+++h'..w7%%g.??6>>&--###!''/v}}"6??--"1%C!Q&v}}//!$Q'C,C??C+N$NC8>FW3r7G$F:@//J/;2wSWg&/J++COOM GJs   #HHrI   runtestsreturnc                 X   |j                   r3ddlm}  || j                  ||j                   |j                        \  }}n	 |       }d}|rt
        j                  | _        |xt        d x\    |}|| _        y  xt        j                  d x \    t        j                  |      }|| _        y  $t        | j                   d|        d }|| _        y 	 dd l}t        ||j                        rt        j                   |      }|| _        y t        dt#        |              d }|| _        y )Nr   )runtest_refleakF z test runner returned None: r   zUnknown test result type: )hunt_refleakrefleakrS   	test_namequietr   REFLEAKstater	   r   r   rC   r   doctestr)   TestResultsfrom_doctesttyper4   )rI   	test_funcrP   rS   rV   test_resultr4   r[   s           r#   regrtest_runnerra   R   s#    ,.v/?/?/7/D/D/7~~ ?  k}} Y[E  FL# "X  "++K8E FL #V--..J9+VWE FL  +w':':;!..{;
 FL  :4;L:MNOFLr%   c                    | j                   }t        ||j                        }t        j                  |      t        d      rt        d| d      fd}	 t        | ||       t        j                          t        ||j                         t        j                  rtdt        _        t        | dt!        t        j                         d       t"        j%                  t        j                         t        j                  j'                          t        j(                          y # t        j                          t        ||j                         w xY w)N	test_mainzModule z= defines test_main() which is no longer supported by regrtestc                      t               S r'   )r$   )r   s   r#   r_   z!_load_run_test.<locals>.test_func   s    H%%r%   Tz	 created z uncollectable object(s))rW   r   test_dir	importlibimport_modulehasattrr   ra   r   
gc_collectr   r6   gcgarbageenvironment_alteredr   rD   
GC_GARBAGEextendclearreap_children)rI   rP   rW   module_namer_   r   s        @r#   _load_run_testrr   |   s     I!)X->->?K&&{3Hx%') -= > ? 	?&	3	84 	i!1!12	zz&*#9S_,= >0 1 	2
 	"**%


 	i!1!12s   D* *,Edisplay_failurec                    dt         _        |j                  }|rd}|j                  }| j                  }	 t                t        j                          t        ||j                  ||      5  t        | |       d d d        t         j                  r| jC                          | j                  t        jD                  | _        y y # 1 sw Y   LxY w# t         j                  $ r5}|s|st        | d| d       t        j                  | _        Y d }~y d }~wt        j                   $ r5}|s|st        | d| d       t        j"                  | _        Y d }~y d }~wt         j$                  $ r}}d| d}|r| d| }t        |t&        j(                  d	       t        j*                  | _        |j,                  | _        |j.                  | _        |j0                  | _        Y d }~y d }~wt         j2                  $ r[}d| d}|r| d| }t        |t&        j(                  d	       t        j*                  | _        |j0                  | _        Y d }~y d }~wt         j4                  $ r t        j6                  | _        Y y t8        $ r" t                t        j:                  | _        Y y  |s6t=        j>                         }t        d| d
| t&        j(                  d	       t        j@                  | _        Y y xY w)NF)pgoz skipped -- T)flushtest z failedz -- r   rv    crashed -- )#r   rl   ru   rX   rW   r   ri   r   r6   rr   ResourceDeniedr   r   RESOURCE_DENIEDrZ   r   SkipTestSKIPPEDrG   r   r   FAILEDr   rE   r4   
TestFailedrA   DID_NOT_RUNKeyboardInterruptINTERRUPTED	traceback
format_excUNCAUGHT_EXCset_env_changedPASSED)rI   rP   rs   ru   rX   rW   excmsgs           r#   _runtest_env_changed_excr      sk    #(G
,,C
NNE  I0#I$,$4$4eF68,F\ "" |||| cF F !! SYK|C51>,, SYK|C51>}}(( 	i[(EcU#Cc

$/||

,,yy i[(EcU#Cc

$/||yy   (( ((&&(CE)L6zz/))sb   7C ,C9C C	C K9#+DK9)+EK9/A3G''K9=AI+K9 'K9)AK9c                 $   |j                   }|j                  }|j                  }|*t        j                  rd}t        j                  |d       nd}	 t        |       |rdt        _         t        j                         }t        j                  }t        j                  }t        j                  }	|	j                  }
d }	 |t        _        |t        _        ||	_        t!        | |d       | j"                  t$        j&                  k7  r|j)                         }|t        _        |t        _        |
|	_        |Xt        j                  j+                  |       t        j                  j-                          n|t        _         t!        | ||        t        j.                  }|r|| _        |rt        j2                          d t        _        y # |t        _        |t        _        |
|	_        w xY w# |rt        j2                          d t        _        w xY w)NT)exitF)rs   )r6   output_on_failuretimeoutr   can_start_threadfaulthandlerdump_traceback_laterr   r   ioStringIOr   r5   r   r   orig_stderrr   rZ   r   r   getvaluewriterv   r7   xml_datacancel_dump_traceback_later)rI   rP   r6   r   r   use_timeoutstreamorig_stdoutr   r   orig_print_warnings_stderroutputxml_lists                r#   _runtestr      s    G 22G/@@))'=-&H"GO[[]F**K**K#11M)6)B)B&FG#
#
 -3)(5Q<<5<</#__.F(
(
,F)!

  (

  " &GO$VX9@[B ))&FO446!%' )
(
,F) 446!%s'   A+G,  AG
 BG, 
G))G, ,#HrW   c                    	 t        j                         }t        |       }|j                  }	 t	        ||       t        j                  j                          t        j                  j                          t        j                         |z
  |_        |S #  |s6t        j                         }t        d|  d| t        j                  d       t        j                  |_        Y xY w)Nrw   ry   Trx   )timeperf_counterr   ru   r   r   r   r   r   r   r   r   rZ   r5   rv   duration)rW   rP   
start_timerI   ru   r   s         r#   run_single_testr   %  s     ""$J	"F
,,C*" JJJJ'')J6FOM*&&(CE)L6zz/))s   B AC%)T)+r   rj   rf   r   r   r   r   r   r/   r   test.supportr   filterr   rI   r   r   r	   rP   r
   save_envr   setupr   
testresultr   utilsr   r   r   r   r   PROGRESS_MIN_TIMEr$   r   r   ra   rm   rr   boolr   r   r   rT   r%   r#   <module>r      s     	  	 
     )  0 0  ,  'A A  
>#J #X #$ #N 
": " "d "L 6:D$Z D$8 D$.2D$>BD$N:&Z :&8 :& :&zx 8 
 r%   