
    ;e                         	 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	  G d dej
                  Zd Zed	k    r e e                       dS dS )
    N)run_unittest)EnvironmentVarGuard)	sysconfig)UnixCCompilerc                       e Zd Zd Zd Z ej        ej        dk    d          d             Z	 ej
        ej        dk    d          d             Z ej
        ej        dk    d          d	             Zd
S )UnixCCompilerTestCasec                     t           j        | _        t          j        | _        t          t          j                  | _         G d dt                    } |            | _
        d S )Nc                       e Zd Zd ZdS )4UnixCCompilerTestCase.setUp.<locals>.CompilerWrapperc                 ,    |                      d          S )Nz/foo)runtime_library_dir_optionselfs    9/usr/lib/python3.11/distutils/tests/test_unixccompiler.py	rpath_fooz>UnixCCompilerTestCase.setUp.<locals>.CompilerWrapper.rpath_foo   s    66v>>>    N)__name__
__module____qualname__r    r   r   CompilerWrapperr      s#        ? ? ? ? ?r   r   )sysplatform_backup_platformr   get_config_var_backup_get_config_vardict_config_vars_backup_config_varsr   cc)r   r   s     r   setUpzUnixCCompilerTestCase.setUp   si     #&/&>##'	(>#?#? 	? 	? 	? 	? 	?m 	? 	? 	? "/##r   c                     | j         t          _        | j        t          _        t          j                                         t          j                            | j	                   d S N)
r   r   r   r   r   r   r   clearupdater   r   s    r   tearDownzUnixCCompilerTestCase.tearDown   sL    ,#'#>	 $$&&&%%d&>?????r   win32zcan't test on Windowsc                    dt           _        |                     | j                                        d           dt           _        t
          j        }d }|t
          _        |                     | j                                        ddg           d }|t
          _        |                     | j                                        ddg           d }|t
          _        |                     | j                                        ddg           |t
          _        d	t           _        d
 }|t
          _        |                     | j                                        d           d	t           _        d }|t
          _        |                     | j                                        d           d	t           _        d }|t
          _        |                     | j                                        d           d	t           _        d }|t
          _        |                     | j                                        d           d	t           _        d }|t
          _        |                     | j                                        d           d S )Ndarwinz-L/foozhp-uxc                     dS )Nxxxr   vs    r   gcvz=UnixCCompilerTestCase.test_runtime_libdir_option.<locals>.gcv)       5r   z+sc                     dS )Ngccr   r,   s    r   r.   z=UnixCCompilerTestCase.test_runtime_libdir_option.<locals>.gcv.   r/   r   z-Wl,+sc                     dS )Nzg++r   r,   s    r   r.   z=UnixCCompilerTestCase.test_runtime_libdir_option.<locals>.gcv3   r/   r   barc                 &    | dk    rdS | dk    rdS d S )NCCr1   GNULDyesr   r,   s    r   r.   z=UnixCCompilerTestCase.test_runtime_libdir_option.<locals>.gcv<   s%    Dyyugu r   z-Wl,--enable-new-dtags,-R/fooc                 &    | dk    rdS | dk    rdS d S )Nr5   r1   r6   nor   r,   s    r   r.   z=UnixCCompilerTestCase.test_runtime_libdir_option.<locals>.gcvF   s%    Dyyugt r   z
-Wl,-R/fooc                 &    | dk    rdS | dk    rdS d S )Nr5   zx86_64-pc-linux-gnu-gcc-4.4.2r6   r7   r   r,   s    r   r.   z=UnixCCompilerTestCase.test_runtime_libdir_option.<locals>.gcvQ   s&    Dyy66gu r   c                 &    | dk    rdS | dk    rdS d S )Nr5   r    r6   r7   r   r,   s    r   r.   z=UnixCCompilerTestCase.test_runtime_libdir_option.<locals>.gcv[   s%    Dyytgu r   z-R/fooc                 &    | dk    rdS | dk    rdS d S )Nr5   r    r6   r9   r   r,   s    r   r.   z=UnixCCompilerTestCase.test_runtime_libdir_option.<locals>.gcve   s%    Dyytgt r   )r   r   assertEqualr    r   r   r   )r   old_gcvr.   s      r   test_runtime_libdir_optionz0UnixCCompilerTestCase.test_runtime_libdir_option   sn     **,,h777 *	 	 	#&	 **,,tX.>???	 	 	#&	 **,,x.BCCC	 	 	#&	 **,,x.BCCC#*	  	 	 	
 $'	 **,,.MNNN 	 	 	
 $'	 **,,l;;; 	 	 	
 $'	 **,,.MNNN 	 	 	
 $'	 **,,h777 	 	 	
 $'	 **,,h77777r   r)   ztest only relevant for OS Xc                     d }|t           _        t                      5 }d|d<   |d= t          j        | j                   d d d            n# 1 swxY w Y   |                     | j        j        d         d           d S )Nc                     | dk    rdS dS NLDSHAREDz*gcc-4.2 -bundle -undefined dynamic_lookup zgcc-4.2r   r,   s    r   r.   zAUnixCCompilerTestCase.test_osx_cc_overrides_ldshared.<locals>.gcvq       JCC9r   my_ccr5   rC   r   r   r   r   customize_compilerr    r=   	linker_sor   r.   envs      r   test_osx_cc_overrides_ldsharedz4UnixCCompilerTestCase.test_osx_cc_overrides_ldsharedm   s    	 	 	 $'	  "" 	2cCIJ(111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	*1-w77777s   "AAAc                    d }|t           _        t                      5 }d|d<   d|d<   t          j        | j                   d d d            n# 1 swxY w Y   |                     | j        j        d         d           d S )Nc                     | dk    rdS dS rB   r   r,   s    r   r.   z=UnixCCompilerTestCase.test_osx_explicit_ldshared.<locals>.gcv   rD   r   rE   r5   zmy_ld -bundle -dynamicrC   r   my_ldrF   rI   s      r   test_osx_explicit_ldsharedz0UnixCCompilerTestCase.test_osx_explicit_ldshared|   s    
	 	 	 $'	  "" 	2cCI6C
O(111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	*1-w77777s   $AAAN)r   r   r   r!   r&   unittestskipIfr   r   r?   
skipUnlessrK   rO   r   r   r   r   r   
   s        $ $ $@ @ @ X_S\W,.EFFO8 O8 GFO8b X13PQQ8 8 RQ8 X13PQQ8 8 RQ8 8 8r   r   c                  X    t          j                                        t                    S r#   )rP   
TestLoaderloadTestsFromTestCaser   r   r   r   
test_suiterV      s       667LMMMr   __main__)r   rP   test.supportr   test.support.os_helperr   	distutilsr   distutils.unixccompilerr   TestCaser   rV   r   r   r   r   <module>r]      s    ( 



  % % % % % % 6 6 6 6 6 6       1 1 1 1 1 1@8 @8 @8 @8 @8H- @8 @8 @8FN N N zL r   