
    /hh^                         S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S r
S rS rS rS rSS jrS rS	 r\S
:X  a  \" 5         gg)    Nc                     [        U S5       nU H  n[        X2S9  M     UR                  5         S S S 5        g ! , (       d  f       g = f)Nw)file)openprintflush)filenametestsfpnames       8/opt/python-3.13.8/usr/lib/python3.13/test/bisect_cmd.pywrite_testsr      s5    	h	D$  

 
		s	   #9
Ac                 d    U (       d  g [        S[        U5      < SU < 35        [        X5        U $ )NzWriting z tests into )r   lenr   )r	   r
   s     r   write_outputr   &   s&    	E
H
=> O    c                 $    SR                  U 5      $ )N )join)argss    r   format_shell_argsr   .   s    88D>r   c                      [         R                  /n U R                  [        R                  " 5       5        U R                  [        R
                  " 5       5        U R                  S5        U $ )N)z-Xfaulthandler)sys
executableextend
subprocess_args_from_interpreter_flags"_optim_args_from_interpreter_flags)cmds    r   
python_cmdr!   2   sJ    >>
CJJz6689JJz<<>?JJ%&Jr   c                    [        5       nUR                  / SQ5        UR                  U R                  5        [        R                  " U[        R
                  SS9nUR                  nU(       a4  [        U5      n[        SU< SU< 35        [        R                  " U5        UR                  R                  5       nU$ )N)-mtestz--list-casesT)stdoutuniversal_newlineszFailed to list tests: z failed with exit code )r!   r   	test_argsr   runPIPE
returncoder   r   r   exitr%   
splitlines)r   r    procexitcoder
   s        r   
list_casesr/   :   s    
,CJJ-.JJt~~>>#!+-13D H$h  	!KK""$ELr   c                    [         R                  " 5       n [        X15        [        5       nUR	                  SSSSU/5        UR	                  U R
                  5        [        S[        U5      -  5        [        R                  R                  5         [        R                  R                  5         [        R                  " U5      nUR                  [        R                   R#                  U5      (       a  [        R$                  " U5        $ $ ! [        R                   R#                  U5      (       a  [        R$                  " U5        f f = f)Nz-ur#   r$   z--matchfilez+ %s)tempfilemktempr   r!   r   r'   r   r   r   r%   r   stderrr   r(   r*   ospathexistsunlink)r   r
   
huntrleakstmpr    r-   s         r   	run_testsr:   K   s    
//
CCl

D$s;<

4>>"f(--.



~~c"77>>#IIcN 277>>#IIcN s   B:D =E
c                      [         R                  " 5       n U R                  SSSS9  U R                  SSSS9  U R                  SS	[        S
SS9  U R                  SS[        SSS9  U R	                  5       u  pX!l        U$ )Nz-iz--inputzUTest names produced by --list-tests written into a file. If not set, run --list-tests)helpz-oz--outputzResult of the bisectionz-nz--max-tests   z:Maximum number of tests to stop the bisection (default: 1))typedefaultr<   z-Nz
--max-iterd   z5Maximum number of bisection iterations (default: 100))argparseArgumentParseradd_argumentintparse_known_argsr'   )parserr   r'   s      r   
parse_argsrG   _   s    $$&F
iI  J j6  8
m#q,  - lc.  /
 --/ODNKr   c                  J   [        5       n S H-  nXR                  ;   d  M  [        SU S35        [        5         M/     U R                  (       a>  [	        U R                  5       nU Vs/ s H  o3R                  5       PM     nnS S S 5        O[        U 5      n[        S[        W5      -  5        [        S[        U R                  5      -  5        [        SU R                  < SU R                  < S35        [        U R                  U5      n[        5         [        R                  " 5       nS	n [        U5      U R                  :  Ga   XpR                  ::  Ga  [        U5      n[        US
-  S	5      n[         R"                  " XH5      n	[        SU SU R                   S[        U	5       S[        U5       35        [        5         [%        X	5      n
[        SU< S[        U5      < 35        [        SU
5        U
(       a$  [        S5        U	n[        U R                  U5      nO[        S5        [        5         US	-  n[        U5      U R                  :  a  XpR                  ::  a  GM  [        S[        U5      -  5        U H  n[        SU-  5        M     [        5         U(       a  [        SU-  5        [(        R*                  " [        R                  " 5       U-
  5      n[        U5      U R                  ::  a&  [        SU< S[,        R.                  " US9< 35        g [        SU< S[,        R.                  " US9< 35        [0        R2                  " S	5        g s  snf ! , (       d  f       GN= f! [&         a#    [        5         [        S5        [        5          GN7f = f)N)z-wz--rerunz
--verbose2z	WARNING: z% option should not be used to bisect!zStart bisection with %s testszTest arguments: %sz!Bisection will stop when getting z1 or less tests (-n/--max-tests option), or after z" iterations (-N/--max-iter option)r=      z[+] Iteration /z: run z tests/zran r+   z*Tests failed: continuing with this subtestz;Tests succeeded: skipping this subtest, trying a new subsetzBisection interrupted!zTests (%s):z* %szOutput written into %szBisection completed in z iterations and )secondszBisection failed after )rG   r'   r   inputr   stripr/   r   r   	max_testsmax_iterr   outputtime	monotonicmaxrandomsampler:   KeyboardInterruptmathceildatetime	timedeltar   r+   )r   optr   liner
   rP   
start_time	iterationntestsubtestsr.   r$   dts                r   mainrb   s   s   <D... IcU"GHIG /
 zz$**.01bdZZ\bE1  4 	
)CJ
67	
!24>>!B
BC	 ^^T]], - $++u-F	G!JI%j4>>)i==.HJE
A&E}}U2HN9+Qt}}o >Xws5zl< =G 0Huc%j9:&(#BC %dkk59STGNI) %j4>>)i==.H4 
-#e*
$%ftm 	G&/0	4>>#j0	1B
5zT^^#H..r:< 	= 	H..r:< 	=s 2 L  &'s1   $M#)MM#0D7M5 M##
M25)N"!N"__main__)N)rA   rY   os.pathr4   rW   rT   r   r   r1   rQ   r   r   r   r!   r/   r:   rG   rb   __name__ r   r   <module>rg      s`   (       
  "((BJ zF r   