HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //proc/thread-self/root/usr/local/lib/python3.7/test/__pycache__/bisect_cmd.cpython-37.pyc
B

��gg�@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
dd�Zdd�Zdd�Z
d	d
�Zddd�Zd
d�Zdd�Zedkr�e�dS)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
�Nc	Cs<t|d��(}x|D]}t||d�qW|��WdQRXdS)N�w)�file)�open�print�flush)�filename�tests�fp�name�r�+/usr/local/lib/python3.7/test/bisect_cmd.py�write_testss
r
cCs*|sdStdt|�|f�t||�|S)NzWriting %s tests into %s)r�lenr
)rrrrr�write_output&s

rcCs
d�|�S)N� )�join)�argsrrr�format_shell_args.srcCsftjdddg}|�|j�tj|tjdd�}|j}|rXt|�}t	d||f�t�
|�|j��}|S)Nz-m�testz--list-casesT)�stdoutZuniversal_newlinesz1Failed to list tests: %s failed with exit code %s)
�sys�
executable�extend�	test_args�
subprocess�run�PIPE�
returncoderr�exitr�
splitlines)r�cmd�proc�exitcoderrrr�
list_cases2s

r#c	Cslt��}zFt||�tjddd|g}|�|j�tdt|��t	�
|�}|jStj
�|�rft�|�XdS)Nz-mrz--matchfilez+ %s)�tempfileZmktempr
rrrrrrrrr�os�path�exists�unlink)rrZ
huntrleaksZtmpr r!rrr�	run_testsBs

r)cCsft��}|jdddd�|jdddd�|jdd	td
dd�|jd
dtddd�|��\}}||_|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-tests�z:Maximum number of tests to stop the bisection (default: 1))�type�defaultr*z-Nz
--max-iter�dz5Maximum number of bisection iterations (default: 100))�argparse�ArgumentParser�add_argument�int�parse_known_argsr)�parserrrrrr�
parse_argsQsr5c	Cs&t�}|jr2t|j��}dd�|D�}WdQRXnt|�}tdt|��tdt|j��td|j|j	f�t
|j|�}t�t�
�}d}y�x�t|�|jk�rP||j	k�rPt|�}t|dd�}t�||�}td|t|�t|�f�t�t||�}td	|t|�f�td
|�|�r8td�|}t
|j|�}ntd�t�|d7}q�WWn*tk
�r~t�td
�t�YnXtdt|��x|D]}	td|	��q�Wt�|�r�td|�t�t�
�|�}
t|�|jk�r
td|tj|
d�f�t�d�ntd|tj|
d�f�dS)NcSsg|]}|���qSr)�strip)�.0�linerrr�
<listcomp>jszmain.<locals>.<listcomp>zStart bisection with %s testszTest arguments: %szxBisection will stop when getting %s or less tests (-n/--max-tests option), or after %s iterations (-N/--max-iter option)r+�z![+] Iteration %s: run %s tests/%szran %s tests/%srz*Tests failed: continuing with this subtestz;Tests succeeded: skipping this subtest, trying a new subsetzBisection interrupted!zTests (%s):z* %szOutput written into %sz+Bisection completed in %s iterations and %s)Zsecondsz+Bisection failed after %s iterations and %s)r5�inputrr#rrrrZ	max_testsZmax_iterr�output�timeZ	monotonic�max�randomZsampler)�KeyboardInterrupt�mathZceil�datetimeZ	timedeltarr)rr	rr<Z
start_timeZ	iterationZntestZsubtestsr"rZdtrrr�maines`


rC�__main__)N)�__doc__r/rBZos.pathr%rAr?rrr$r=r
rrr#r)r5rC�__name__rrrr�<module>s$
A