python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
bisect_cmd.cpython-312.pyc

͑edZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
dZdZdZ
dZdZddZd	Zd
Zedk(reyy)
a
Command line tool to bisect failing CPython tests.

Find the test_os test method which alters the environment:

    ./python -m test.bisect_cmd --fail-env-changed test_os

Find a reference leak in "test_os", write the list of failing tests into the
"bisect" file:

    ./python -m test.bisect_cmd -o bisect -R 3:3 test_os

Load an existing list of tests from a file using -i option:

    ./python -m test --list-cases -m FileTests test_os > tests
    ./python -m test.bisect_cmd -i tests test_os
Nct|d5}|D]}t|||jdddy#1swYyxYw)Nw)file)openprintflush)filenametestsfpnames    C/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/bisect_cmd.pywrite_testsrsE	
h		!D$R 	!

s	%;AcX|sytdt|d|t|||S)NzWriting z tests into )rlenr)r	r
s  r
write_outputr&s(	E
H
=>% Oc$dj|S)N )join)argss r
format_shell_argsr.s88D>rctjg}|jtj|jtj
|SN)sys
executableextend
subprocess_args_from_interpreter_flags"_optim_args_from_interpreter_flags)cmds r

python_cmdr!2s=>>
CJJz6689JJz<<>?Jrctt}|jgd|j|jtj|tj
d}|j}|r1t|}td|d|tj||jj}|S)N)-mtestz--list-casesT)stdoutuniversal_newlineszFailed to list tests: z failed with exit code )
r!r	test_argsrrunPIPE
returncoderrrexitr%
splitlines)rr procexitcoder
s     r

list_casesr/9s
,CJJ-.JJt~~>>#!+-13DH$
h 	!KK""$ELrctj}	t||t}|j	ddd|g|j	|j
t
dt|ztj|}|jtjj|rtj|SS#tjj|rtj|wwxYw)Nr#r$z--matchfilez+ %s)tempfilemktemprr!rr'rrrr(r*ospathexistsunlink)rr

huntrleakstmpr r-s      r
	run_testsr9Js
//
CCl

D&-56

4>>"
f(--.~~c"
77>>#IIcN277>>#IIcNsA=C		7Dctj}|jddd|jddd|jdd	td
d|jd
dtdd|j	\}}||_|S)Nz-iz--inputzUTest names produced by --list-tests written into a file. If not set, run --list-tests)helpz-oz--outputzResult of the bisectionz-nz--max-testsz:Maximum number of tests to stop the bisection (default: 1))typedefaultr;z-Nz
--max-iterdz5Maximum number of bisection iterations (default: 100))argparseArgumentParseradd_argumentintparse_known_argsr')parserrr's   r

parse_argsrFZs

$
$
&F
iIJj68
m#q,-lc./
--/OD)DNKrc
t}dD]*}||jvstd|dt,|jr<t	|j5}|Dcgc]}|j}}dddnt
|}tdtztdt|jztd|jd|jdt|j|}ttj}d	}	t||jkDr	||jkrt|}t|d
zd	}t!j"||}	td|dt|	d
t|tt%||	}
td|d
t|td|
|
r$td|	}t|j|}ntdt|d	z
}t||jkDr||jkrtdt|z|D]}td|zt|rtd|zt)j*tj|z
}t||jkr;td|dt-j.|t1j2d	ytd|dt-j.|ycc}w#1swYxYw#t&$r#ttdtY&wxYw)N)z-wz--rerunz
--verbose2z	WARNING: z% option should not be used to bisect!zStart bisection with %s testszTest 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/zran r+z*Tests failed: continuing with this subtestz;Tests succeeded: skipping this subtest, trying a new subsetzBisection interrupted!zTests (%s):z* %szOutput written into %szBisection completed in z iterations and )secondszBisection failed after )rFr'rinputrstripr/rr	max_testsmax_iterroutputtime	monotonicmaxrandomsampler9KeyboardInterruptmathceildatetime	timedeltarr+)
roptrliner
rN
start_time	iterationntestsubtestsr.r$dts
             r
mainr`ns<D.$.. IcU"GHIG
zz
$**
	2.01dTZZ\1E1	2	24 	
)CJ
67	
!24>>!B
BC	^^T]],-$++u
-F	G!JI%j4>>)i4==.HJE
A&E}}UE2HH
s5z;
<G x0Huc%j9:&(#BC %dkk59STGNI)%j4>>)i4==.H4
-#e*
$%
ftm	G

&/0	
4>>#j0	1B
5zT^^#
H..r:<	=
H..r:<	=q2	2	2L

&'
s1L2 L-7L2"D!L?-L22L<?(M+*M+__main__r)__doc__r@rWos.pathr3rUrRrrr1rOrrrr!r/r9rFr`__name__rr
<module>rfse$

"
 (B=JzFr