o
    5‘ðië  ã                   @   sR   d Z ddlZddlmZ ddlmZ ddlmZmZ ddl	Z	G dd„ dej
ƒZdS )z'Tests for distutils.command.build_clib.é    N)Ú
build_clib)ÚDistutilsSetupError)Úmissing_compiler_executableÚsupportc                   @   s@   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zej 	d	¡d
d„ ƒZ
dS )ÚTestBuildCLibc                 C   sN  |   ¡ \}}t|ƒ}t t¡� | d¡ W d   ƒ n1 sw   Y  t t¡� | ddg¡ W d   ƒ n1 s;w   Y  t t¡� | ddg¡ W d   ƒ n1 sWw   Y  t t¡� | ddg¡ W d   ƒ n1 ssw   Y  t t¡� | di fd	g¡ W d   ƒ n1 s‘w   Y  di fdd
difg}| |¡ d S )NÚfooÚfoo1Úfoo2)é   r   )Únamer	   )r   r   )zanother/namer	   r   )Úanotherr	   ÚokÚgood)Úcreate_distr   ÚpytestÚraisesr   Úcheck_library_list)ÚselfÚpkg_dirÚdistÚcmdÚlibs© r   új/root/parts/websockify/install/lib/python3.10/site-packages/setuptools/_distutils/tests/test_build_clib.pyÚtest_check_library_dist   s.   ÿÿÿÿÿ
ÿÿz%TestBuildCLib.test_check_library_distc                 C   s  |   ¡ \}}t|ƒ}di fg|_t t¡� | ¡  W d   ƒ n1 s$w   Y  dddifg|_t t¡� | ¡  W d   ƒ n1 sEw   Y  ddddgifg|_| ¡ ddgks^J ‚dddifg|_| ¡ ddgkspJ ‚dddifdddd	gifg|_| ¡ g d
¢ks‰J ‚d S )Nr   Úsourcesr
   ÚaÚb)r   r   Úname2ÚcÚd)r   r   r   r    )r   r   Ú	librariesr   r   r   Úget_source_files©r   r   r   r   r   r   r   Útest_get_source_files-   s$   
ÿ
ÿ
þz#TestBuildCLib.test_get_source_filesc                 C   s¤   |   ¡ \}}t|ƒ}G dd„ dƒ}|ƒ |_dddifg}t t¡� | |¡ W d   ƒ n1 s1w   Y  ddtƒ ifg}| |¡ ddtƒ ifg}| |¡ d S )Nc                   @   s   e Zd Zdd„ ZeZdS )z8TestBuildCLib.test_build_libraries.<locals>.FakeCompilerc                  _   s   d S )Nr   )ÚargsÚkwr   r   r   ÚcompileL   s   z@TestBuildCLib.test_build_libraries.<locals>.FakeCompiler.compileN)Ú__name__Ú
__module__Ú__qualname__r'   Úcreate_static_libr   r   r   r   ÚFakeCompilerK   s    r,   r   r   Únotvalid)	r   r   Úcompilerr   r   r   Úbuild_librariesÚlistÚtuple)r   r   r   r   r,   Úlibr   r   r   Útest_build_librariesG   s   ÿ
z"TestBuildCLib.test_build_librariesc                 C   sŽ   |   ¡ \}}t|ƒ}d|_| ¡  |jdgksJ ‚d |_| ¡  |jg ks'J ‚d|j_t t¡� | ¡  W d   ƒ d S 1 s@w   Y  d S )Nzone-dirÚWONTWORK)	r   r   Úinclude_dirsÚfinalize_optionsÚdistributionr!   r   r   r   r#   r   r   r   Útest_finalize_options^   s   
"ÿz#TestBuildCLib.test_finalize_optionszplatform.system() == "Windows"c                 C   s¢   |   ¡ \}}t|ƒ}tj |d¡}|  |d¡ dd|gifg|_tj |d¡}t |¡ ||_||_t	ƒ }|d urB|  
d|›d�¡ | ¡  dt |¡v sOJ ‚d S )	Nzfoo.czint main(void) { return 1;}
r   r   ÚbuildzThe z command is not foundzlibfoo.a)r   r   ÚosÚpathÚjoinÚ
write_filer!   ÚmkdirÚ
build_tempr   ÚskipTestÚrunÚlistdir)r   r   r   r   Úfoo_cr?   Úccmdr   r   r   Útest_runn   s   
zTestBuildCLib.test_runN)r(   r)   r*   r   r$   r3   r8   r   ÚmarkÚskipifrE   r   r   r   r   r      s    !
r   )Ú__doc__r:   Údistutils.command.build_clibr   Údistutils.errorsr   Údistutils.testsr   r   r   ÚTempdirManagerr   r   r   r   r   Ú<module>   s    