a
    åzeÏ  ã                   @   sˆ   d dl Z d dlZd dlZd dlmZmZ d dlmZmZ d dl	m
Z
 d dlmZ G dd„ de
je
je jƒZdd	„ Zed
kr„eeƒ ƒ dS )é    N)Úrun_unittestÚmissing_compiler_executable)Ú	dump_fileÚconfig)Úsupport)Úlogc                       sb   e Zd Zdd„ Z‡ fdd„Z‡ fdd„Zdd„ Ze e	j
d	kd
¡dd„ ƒZdd„ Zdd„ Z‡  ZS )ÚConfigTestCasec                 G   s   |  ¡ D ]}| j |¡ qd S ©N)Ú
splitlinesÚ_logsÚappend)ÚselfÚmsgÚargsÚline© r   ú5/usr/lib/python3.9/distutils/tests/test_config_cmd.pyÚ_info   s    zConfigTestCase._infoc                    s(   t t| ƒ ¡  g | _tj| _| jt_d S r	   )Úsuperr   ÚsetUpr   r   ÚinfoÚold_logr   ©r   ©Ú	__class__r   r   r      s    zConfigTestCase.setUpc                    s   | j t_tt| ƒ ¡  d S r	   )r   r   r   r   r   ÚtearDownr   r   r   r   r      s    zConfigTestCase.tearDownc                 C   sd   t j t¡d d }t|ƒ}zt| ¡ ƒ}W | ¡  n
| ¡  0 t|dƒ |  	t| j
ƒ|d ¡ d S )Nr   z.pyzI am the headeré   )ÚosÚpathÚsplitextÚ__file__ÚopenÚlenÚ	readlinesÚcloser   ÚassertEqualr   )r   Z	this_fileÚfZnumlinesr   r   r   Útest_dump_file   s    
zConfigTestCase.test_dump_fileÚwin32zcan't test on Windowsc                 C   s¨   t dgƒ}|d ur |  d| ¡ |  ¡ \}}t|ƒ}| ¡  |j}tjd d… dkrpd|jd  	¡ v rp|  d¡ |j
dd	d
}|  |d¡ |j
dd	d
}|  |d¡ d S )NÚpreprocessorzThe %r command is not foundé   ZaixZxlcr   zAxlc: The -E option overrides the -P, -o, and -qsyntaxonly optionsÚxxxz	/* xxx */)ÚpatternÚbodyZ_configtestr   )r   ZskipTestÚcreate_distr   Z_check_compilerÚcompilerÚsysÚplatformr)   ÚlowerZ
search_cppr%   )r   ÚcmdÚpkg_dirÚdistr/   Úmatchr   r   r   Útest_search_cpp(   s    
$
zConfigTestCase.test_search_cppc                 C   sr   |   ¡ \}}t|ƒ}dtj |_d|_dtj |_| ¡  |  |jddg¡ |  |jdg¡ |  |jddg¡ d S )Nzone%stwoÚonezthree%sfourÚtwoZthreeZfour)	r.   r   r   ÚpathsepZinclude_dirsZ	librariesZlibrary_dirsZensure_finalizedr%   )r   r4   r5   r3   r   r   r   Útest_finalize_options;   s    z$ConfigTestCase.test_finalize_optionsc                 C   s    |   ¡ }tj |d¡}tj |d¡}|  |d¡ |  |d¡ ||fD ]}|  tj |¡¡ qD|  ¡ \}}t|ƒ}| 	||¡ ||fD ]}|  
tj |¡¡ q„d S )Nr8   r9   r+   )Úmkdtempr   r   ÚjoinZ
write_fileZ
assertTrueÚexistsr.   r   Z_cleanZassertFalse)r   Ztmp_dirÚf1Úf2r&   r4   r5   r3   r   r   r   Ú
test_cleanI   s    zConfigTestCase.test_clean)Ú__name__Ú
__module__Ú__qualname__r   r   r   r'   ÚunittestZskipIfr0   r1   r7   r;   rA   Ú__classcell__r   r   r   r   r      s   
r   c                   C   s
   t  t¡S r	   )rE   Z	makeSuiter   r   r   r   r   Ú
test_suite\   s    rG   Ú__main__)rE   r   r0   Ztest.supportr   r   Zdistutils.command.configr   r   Zdistutils.testsr   Z	distutilsr   ZLoggingSilencerZTempdirManagerZTestCaser   rG   rB   r   r   r   r   Ú<module>   s   þQ