Your IP : 216.73.216.213


Current Path : /opt/alt/python38/lib64/python3.8/test/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/test/__pycache__/bisect_cmd.cpython-38.opt-2.pyc

U

i�fs�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	dd�Z
dd�Zdd�Zdd	�Z
dd
d�Zdd
�Zdd�Zedkr�e�dS)�Nc	Cs8t|d��$}|D]}t||d�q|��W5QRXdS)N�w)�file)�open�print�flush)�filename�tests�fp�name�r�4/opt/alt/python38/lib64/python3.8/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)N�-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	Cspt��}zJt||�tjddd|g}|�	|j
�tdt|��t
�|�}|jW�Stj�|�rjt�|�XdS)Nrrz--matchfilez+ %s)�tempfileZmktemp�os�path�exists�unlinkr
rrrrrrrrr)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�intZparse_known_argsr)�parserrrrrr�
parse_argsQs ����r5c	Cst�}|jr2t|j��}dd�|D�}W5QRXnt|�}tdt|��tdt|j��td|j|j	f�t
|j|�}t�t�
�}d}z�t|�|jk�rN||j	k�rNt|�}t|dd�}t�||�}td|t|�t|�f�t�t||�}td	|t|�f�td
|�|�r6td�|}t
|j|�}ntd�t�|d7}q�Wn*tk
�rzt�td
�t�YnXtdt|��|D]}	td|	��q�t�|�r�td|�t�t�
�|�}
t|�|jk�rtd|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�time�	monotonic�max�randomZsampler*�KeyboardInterrupt�mathZceil�datetimeZ	timedeltarr)rr	rr<Z
start_timeZ	iterationZntestZsubtestsr#rZdtrrr�mainesh
��

��rD�__main__)N)r0rCZos.pathr&rBr@rrr%r=r
rrr$r*r5rD�__name__rrrr�<module>s"
A