o
    2g                     @  s   d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	m
Z
 ddlmZ ddlmZ ddlmZmZ dgZejejed	d	ZejZG d
d deZdS )zTest cases for invoking mypyc on the command line.

These are slow -- do not add test cases unless you have a very good reason to do so.
    )annotationsN)test_temp_dir)DataDrivenTestCase)normalize_error_messages)MypycDataSuiteassert_test_outputzcommandline.testz..c                   @  s"   e Zd ZeZeZdZd	ddZdS )
TestCommandLineTtestcaser   returnNonec              
   C  s  d |j}td|}|d usJ d|d }d|j }tj t	|}t
|d}|| W d    n1 s<w   Y  tj }t|d< d}	zctjtjd	d
g|tjtjd|d}
d|jv si|
jdkro|	|
j7 }	nd|jv r|
jd\}}}|	|7 }	|
jdkr|	tjt|gdd7 }	W tjdkrdnd}tjd| dd}|D ]}t| qntjdkrdnd}tjd| dd}|D ]}t| qw dd |jD }t|	   }t!||d|d d S )N
z# *cmd: *(.*)z*Test case missing "# cmd: <files>" section   z_%s.pyw
PYTHONPATH    z-mmypyctmp)stdoutstderrcwdenvErrorOutputr   WarningOutputs   running build_ext)r   win32pydsoz	tmp/**/*.T)	recursivec                 S  s   g | ]}| d dqS )ztmp/ )replace).0x r!   S/home/garg/my-data/venv/lib/python3.10/site-packages/mypyc/test/test_commandline.py
<listcomp>N   s    z,TestCommandLine.run_case.<locals>.<listcomp>zInvalid output)expected)"joininputresearchgroupsplitnameospathr   openwriteenvironcopy	base_path
subprocessrunsys
executablePIPESTDOUT
returncoder   	partitioncheck_outputpython3_pathplatformglobremoveoutputr   decode
splitlinesr   )selfr	   textmargsprogramprogram_pathfr   outcmdmessages_suffixso_pathsr-   r$   actualr!   r!   r"   run_case!   sR   



zTestCommandLine.run_caseN)r	   r   r
   r   )__name__
__module____qualname__filesr   r2   optional_outrQ   r!   r!   r!   r"   r      s
    r   )__doc__
__future__r   r>   r,   os.pathr'   r3   r5   mypy.test.configr   mypy.test.datar   mypy.test.helpersr   mypyc.test.testutilr   r   rU   r-   r%   dirname__file__r2   r6   r<   r   r!   r!   r!   r"   <module>   s     