o
    NZŽhë  ã                   @   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   )Zanotherr	   ÚokZgood)Úcreate_distr   ÚpytestÚraisesr   Zcheck_library_list)ÚselfÚpkg_dirÚdistÚcmdZlibs© r   úZ/var/www/auris/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   Zname2ÚcÚd)r   r   r   r   )r   r   Ú	librariesr   r   r   Z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!   Zcreate_static_libr   r   r   r   ÚFakeCompilerK   s    r%   r   r   Znotvalid)	r   r   Úcompilerr   r   r   Z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-dirZWONTWORK)	r   r   Z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   ZskipTestÚrunÚlistdir)r   r   r   r   Zfoo_cr4   Zccmdr   r   r   Útest_runn   s   
zTestBuildCLib.test_runN)r"   r#   r$   r   r   r*   r-   r   ÚmarkZskipifr7   r   r   r   r   r      s    !
r   )Ú__doc__r/   Zdistutils.command.build_clibr   Zdistutils.errorsr   Zdistutils.testsr   r   r   ZTempdirManagerr   r   r   r   r   Ú<module>   s    