o
    LK&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 sw   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   ^/var/www/html/venv/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sJ 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    