a
    xd                     @   sx   d dl mZ d dlZd dlZd dlZG dd deZG dd deZd dl	Z	d dl
Z
G dd deZG d	d
 d
eZdS )    )absolute_importNc                   @   s   e Zd ZdS )
TestFormatN)__name__
__module____qualname__ r   r   Y/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/lit/formats/base.pyr      s   r   c                   @   s   e Zd Zdd ZdS )FileBasedTestc           
      c   s   | |}t|D ]f}|ds||jv r.qtj||}tj|stj|\}}	|	|j	v rt
j|||f |V  qd S )N.)getSourcePathoslistdir
startswithexcludespathjoinisdirsplitextsuffixeslitTest)
self	testSuitepath_in_suite	litConfiglocalConfigsource_pathfilenamefilepathbaseextr   r   r   getTestsInDirectory   s    


z!FileBasedTest.getTestsInDirectoryN)r   r   r   r!   r   r   r   r   r	      s   r	   c                   @   s.   e Zd ZdddZdd Zdd Zd	d
 ZdS )OneCommandPerFileTestF.*c                 C   sT   t |tr|g| _n
t|| _|d ur.t|}|| _t|| _t|| _	|| _
d S )N)
isinstancestrcommandlistdirbool	recursiverecompilepatternuseTempInput)r   r&   r(   r*   r-   r.   r   r   r   __init__&   s    



zOneCommandPerFileTest.__init__c              
   #   s   | j }|d u r||}t|D ]\}}}| js>g |d d <  fdd|D |d d < |D ]}	|	ds\| j|	r\|	 jv rq\tj	
||	}
|
t|d  }|tjr|dd  }tj||t|tj  }|
|_|V  q\q"d S )Nc                    s"   g | ]}|d kr| j vr|qS )z.svn)r   ).0dr   r   r   
<listcomp>=   s   
z=OneCommandPerFileTest.getTestsInDirectory.<locals>.<listcomp>r
      )r(   r   r   walkr*   r   r-   matchr   r   r   lensepr   r   tuplesplitr   )r   r   r   r   r   r(   dirnamesubdirs	filenamesr   r   suffixtestr   r2   r   r!   3   s0    


z)OneCommandPerFileTest.getTestsInDirectoryc                 C   s   t dd S )NzThis is an abstract method.)NotImplementedError)r   tmpr?   r   r   r   createTempInputR   s    z%OneCommandPerFileTest.createTempInputc           
      C   s  |j jrtjjdfS t| j}| jrRtj	dd}| 
|| |  ||j n&t|drj||j n||  tj|\}}}|| }|s| stjjdfS dddd	 |D  }	| jr|	d
|j 7 }	|	dt|j  7 }	|	d| 7 }	tjj|	fS )NzTest is unsupportedz.cpp)r>   r    zCommand: %s
 c                 S   s   g | ]}d | qS )z'%s'r   )r0   ar   r   r   r3   n   s   z1OneCommandPerFileTest.execute.<locals>.<listcomp>zTemporary File: %s
z--
%s--
zOutput:
--
%s--)configunsupportedr   r   UNSUPPORTEDr'   r&   r.   tempfileNamedTemporaryFilerB   flushappendnamehasattrr   r   utilexecuteCommandstripPASSr   openreadFAIL)
r   r?   r   cmdrA   outerrexitCodeZdiagsreportr   r   r   executeU   s.    


zOneCommandPerFileTest.executeN)Fr#   F)r   r   r   r/   r!   rB   r[   r   r   r   r   r"   "   s     
r"   c                   @   s   e Zd Zdd ZdS )ExecutableTestc                 C   sF   |j jrtjjS tj| \}}}|s6tjjdfS tjj	|| fS )NrC   )
rF   rG   r   r   rH   rO   rP   r   rR   rU   )r   r?   r   rW   rX   rY   r   r   r   r[   |   s    zExecutableTest.executeN)r   r   r   r[   r   r   r   r   r\   {   s   r\   )
__future__r   r   Zlit.Testr   Zlit.utilobjectr   r	   r+   rI   r"   r\   r   r   r   r   <module>   s   Y