
    Ae7                     ^    d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlm	Z	  G d de	      Z
y)    N)
CythonTestc                   6    e Zd Zd Zd Zd Zd Zd Zd Zd Z	y)	TestCyCachec                 @   t        j                  |        t        j                  dt        j
                  j                  d      rdnd       | _        t        j                  d| j                        | _        t        j                  d| j                        | _	        y )Nzcycache-testTEST_TMP)prefixdirsrccache)
r   setUptempfilemkdtempospathisdirtemp_dirsrc_dir	cache_dir)selfs    >lib/python3.12/site-packages/Cython/Build/Tests/TestCyCache.pyr   zTestCyCache.setUp   sl     ((! ggmmJ7
TC  ''u$--H!))dmmL    c                 |    t        j                   t        j                  j                  | j                  |            S N)globr   r   joinr   )r   	file_globs     r   cache_fileszTestCyCache.cache_files   s$    yydnni@AAr   c                     t         j                  j                          d t         j                  j                  _        t        j                  j                  j                  |i | y r   )CythonUtilsclear_function_cachesBuildDependencies	_dep_tree	cythonize)r   argskwargss      r   fresh_cythonizezTestCyCache.fresh_cythonize   sA    **,.2!!+!!++T<V<r   c                    d}d}t         j                  j                  | j                  d      }|d d dz   }t	        |d      j                  |       | j                  || j                         | j                  || j                         | j                  dt        | j                  d	                   t	        |      j                         }t        j                  |       t	        |d      j                  |       | j                  || j                         t	        |      j                         }t        j                  |       | j                  ||d
       | j                  dt        | j                  d	                   t	        |d      j                  |       | j                  || j                         | j                  dt        | j                  d	                   t	        |      j                         }| j                  ||dj                  t        t        j                   |j#                  d      |j#                  d                  d d              y )Nz
value = 1
z
value = 2
a.pyx.cwr      za.c*zC file not changed!   

   )msg)r   r   r   r   openwriter(   r   assertEquallenr   readunlinkassertNotEquallistdifflibunified_diffsplit)r   content1content2a_pyxa_ca_contents1a_contents2
a_contentss           r   test_cycache_switchzTestCyCache.test_cycache_switch   s     T\\73CRj4UCx(U$..9U$..9C 0 0 89:3inn&
		#UCx(U$..93inn&
		#K6KLC 0 0 89:UCx(U$..9C 0 0 89:#Y^^%
		$w33  &(9(9$(? A BBE2G H 	 	Ir   c                    t         j                  j                  | j                  d      }|d d dz   }t	        |d      j                  d       | j                  || j                         t         j                  j                  | j                  t        j                  | j                        d         }t        j                  |d      j                  d	j                  d
             t        j                  |       | j                  || j                         t	        |      j                         }| j                  |d	d|d d z         y )Nr*   r+   r,   r-   passr.   r   wbz
fake stuffasciizUnexpected contents: %s...d   )r   r   r   r   r4   r5   r(   r   listdirgzipGzipFileencoder9   r8   r6   )r   rA   rB   a_cacherE   s        r   test_cycache_uses_cachez#TestCyCache.test_cycache_uses_cache<   s    T\\73CRj4UCv&U$..9'',,t~~rzz$../I!/LMgt$**<+>+>w+GH
		#U$..9#Y^^%
\5
4C8HH	Jr   c                 >   t         j                  j                  | j                  d      }|d d dz   }|d d dz   }|d d dz   }t	        |d      j                  d       | j                  || j                         |||g}|D ]F  }| j                  t         j                  j                  |      |       t        j                  |       H | j                  || j                         |D ]1  }| j                  t         j                  j                  |      |       3 y )	Nr*   r+   r,   z.hz_api.hr-   z)cdef public api int foo(int x): return x
r.   )r   r   r   r   r4   r5   r(   r   
assertTrueexistsr9   )r   rA   rB   a_ha_api_hexpectedoutputs          r   test_multi_file_outputz"TestCyCache.test_multi_file_outputI   s    T\\73CRj4CRj4*x'UCKLU$..9g& 	FOOBGGNN62F;IIf	 	U$..9 	<FOOBGGNN62F;	<r   c                 t   t         j                  j                  | j                  d      }|d t	        d        dz   }t        |d      j                  d       | j                  || j                  d       | j                  dt	        | j                  d	                   t        j                  |       | j                  || j                  d
       | j                  dt	        | j                  d	                   t        j                  |       | j                  || j                  dd       | j                  dt	        | j                  d	                   t        j                  |       | j                  || j                  dd
       | j                  dt	        | j                  d	                   y )Nzoptions.pyxz.pyxr,   r-   rH   F)r   cplusr/   z
options.c*Tr0   )r   r[   show_version)r   r   r   r   r7   r4   r5   r(   r   r6   r   r9   )r   hash_pyxhash_cs      r   test_options_invalidationz%TestCyCache.test_options_invalidationX   sT   77<<m<-CK<(4/Xs!!&)XT^^5IC 0 0 >?@
		&XT^^4HC 0 0 >?@
		&XT^^5W\]C 0 0 >?@
		&XT^^5W[\C 0 0 >?@r   N)
__name__
__module____qualname__r   r   r(   rF   rQ   rY   r_    r   r   r   r      s*    MB=
I<J<Ar   r   )r<   r   rM   r   r   Cython.Build.Dependenciesr   Cython.UtilsCython.TestUtilsr   r   rc   r   r   <module>rg      s-       	     '^A* ^Ar   