
    -Ph                     ~    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Zd dl	Zd dl
Zd dlmZ  G d de          ZdS )    N)
CythonTestc                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )TestCyCachec                 &   t          j        |            t          j        dt          j                            d          rdnd           | _        t          j        d| j                  | _        t          j        d| j                  | _	        d S )Nzcycache-testTEST_TMP)prefixdirsrccache)
r   setUptempfilemkdtempospathisdirtemp_dirsrc_dir	cache_dirselfs    ^/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/Cython/Build/Tests/TestCyCache.pyr   zTestCyCache.setUp   s     (! gmmJ77A

TC C C  'u$-HHH!)dmLLL    c                 p    t          j         t          j                            | j        |                    S N)globr   r   joinr   )r   	file_globs     r   cache_fileszTestCyCache.cache_files   s$    ydni@@AAAr   c                     t           j                                         d t           j        j        _        t          j        j        j        |i | d S r   )CythonUtilsclear_function_cachesBuildDependencies	_dep_tree	cythonizer   argskwargss      r   fresh_cythonizezTestCyCache.fresh_cythonize   sD    **,,,.2!+!+T<V<<<<<r   c                 x    t           j                                         t          j        j        j        |i | d S r   )r    r!   r"   CompilerMaincompiler'   s      r   fresh_compilezTestCyCache.fresh_compile!   s7    **,,,$d5f55555r   c                    d}d}t           j                            | j        d          }|d d         dz   }t	          |d          5 }|                    |           d d d            n# 1 swxY w Y    ||| j                    ||| j                   |                     dt          | 	                    d	                               t	          |          5 }|
                                }d d d            n# 1 swxY w Y   t          j        |           t	          |d          5 }|                    |           d d d            n# 1 swxY w Y    ||| j                   t	          |          5 }|
                                }d d d            n# 1 swxY w Y   t          j        |           |                     ||d
           |                     dt          | 	                    d	                               t	          |d          5 }|                    |           d d d            n# 1 swxY w Y    ||| j                   |                     dt          | 	                    d	                               t	          |          5 }|
                                }	d d d            n# 1 swxY w Y   |                     |	|d                    t          t          j        |	                    d          |                    d                              d d                              d S )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   assertEquallenr   readunlinkassertNotEquallistdifflibunified_diffsplit)
r   compilation_methodcontent1content2a_pyxa_cfa_contents1a_contents2
a_contentss
             r   _test_cycache_switchz TestCyCache._test_cycache_switch&   s     T\733CRCj4% 	GGH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	5777757777C 0 0 8 899:::#YY 	#!&&((K	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#
	#% 	GGH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	57777#YY 	#!&&((K	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#
	#K6KLLLC 0 0 8 899:::% 	GGH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	57777C 0 0 8 899:::#YY 	"!J	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"		$w3  &&(9(9$(?(? A  A B BBE2#G H H 	 	I 	I 	I 	I 	Isl   A))A-0A-C>>DD-EEE;FF #F H::H>H>J==KKc                 :    |                      | j                   d S r   )rO   r*   r   s    r   test_cycache_switch_cythonizez)TestCyCache.test_cycache_switch_cythonizeP   s    !!$"677777r   c                 :    |                      | j                   d S r   )rO   r/   r   s    r   test_cycache_switch_compilez'TestCyCache.test_cycache_switch_compileS   s    !!$"455555r   c                    t           j                            | j        d          }|d d         dz   }t	          |d          5 }|                    d           d d d            n# 1 swxY w Y    ||| j                   t           j                            | j        t          j        | j                  d                   }t          j	        |d          5 }|                    d	           d d d            n# 1 swxY w Y   t          j
        |            ||| j                   t	          |          5 }|                                }d d d            n# 1 swxY w Y   |                     |d
d|d d         z             d S )Nr1   r2   r3   r4   passr5   r   wbs
   fake stuffz
fake stuffzUnexpected contents: %s...d   )r   r   r   r   r;   r<   r   listdirgzipGzipFiler@   r?   r=   )r   rF   rI   rJ   rK   a_cachegzipfilerN   s           r   _test_cycache_uses_cachez$TestCyCache._test_cycache_uses_cacheV   s    T\733CRCj4% 	GGFOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	57777',,t~rz$./I/I!/LMM]7D)) 	*XNN=)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*
	#57777#YY 	"!J	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"\5
4C48HH	J 	J 	J 	J 	Js6   A%%A),A)C;;C?C?;EE #E c                 :    |                      | j                   d S r   )r]   r*   r   s    r   !test_cycache_uses_cache_cythonizez-TestCyCache.test_cycache_uses_cache_cythonizek       %%d&:;;;;;r   c                 :    |                      | j                   d S r   )r]   r/   r   s    r   test_cycache_uses_cache_compilez+TestCyCache.test_cycache_uses_cache_compilen       %%d&899999r   c                 f   t           j                            | j        d          }|d d         dz   }|d d         dz   }t	          |d          5 }|                    d           d d d            n# 1 swxY w Y    ||| j        d           |                     t           j                            |          |           t          j	        |           t          j	        |            ||| j        d           |                     t           j                            |          |           d S )	Nr1   r2   r3   z.htmlr4   rU   default)r   annotate
r   r   r   r   r;   r<   r   
assertTrueexistsr@   )r   rF   rI   rJ   a_htmlrK   s         r   _test_cycache_annotationz$TestCyCache._test_cycache_annotationq   sK   T\733CRCj4ssg%% 	GGFOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	5KKKKv..777
	&
	#5KKKKv..77777s   A22A69A6c                 :    |                      | j                   d S r   )rk   r*   r   s    r   !test_cycache_annotation_cythonizez-TestCyCache.test_cycache_annotation_cythonize   r`   r   c                 :    |                      | j                   d S r   )rk   r/   r   s    r   test_cycache_annotation_compilez+TestCyCache.test_cycache_annotation_compile   rc   r   c                 r   t           j                            | j        d          }|d d         dz   }|d d         dz   }|d d         dz   }t	          |d          5 }|                    d           d d d            n# 1 swxY w Y    ||| j                   |||g}|D ]I}|                     t           j                            |          |           t          j	        |           J ||| j                   |D ]5}|                     t           j                            |          |           6d S )	Nr1   r2   r3   z.hz_api.hr4   z)cdef public api int foo(int x): return x
r5   rg   )	r   rF   rI   rJ   a_ha_api_hrK   expectedoutputs	            r   _test_multi_file_outputz#TestCyCache._test_multi_file_output   s   T\733CRCj4CRCj4*x'% 	BGG@AAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	57777g& 	 	FOOBGNN622F;;;If57777 	< 	<FOOBGNN622F;;;;	< 	<s   A??BBc                 :    |                      | j                   d S r   )ru   r*   r   s    r    test_multi_file_output_cythonizez,TestCyCache.test_multi_file_output_cythonize   s    $$T%9:::::r   c                 :    |                      | j                   d S r   )ru   r/   r   s    r   test_multi_file_output_compilez*TestCyCache.test_multi_file_output_compile   s    $$T%788888r   c                 F   t           j                            | j        d          }|d t	          d                    dz   }|d t	          d                    dz   }t          |d          5 }|                    d           d d d            n# 1 swxY w Y    ||| j        d           |                     d	t	          | 	                    d
                               t          j
        |            ||| j        d           |                     dt	          | 	                    d
                               	 t          j
        |           n$# t          $ r t          j
        |           Y nw xY w ||| j        dd           |                     dt	          | 	                    d
                               t          j
        |            ||| j        dd           |                     dt	          | 	                    d
                               d S )Nzoptions.pyxz.pyxr3   z.cppr4   rU   F)r   cplusr6   z
options.c*Tr7   )r   r{   show_version)r   r   r   r   r>   r;   r<   r   r=   r   r@   FileNotFoundError)r   rF   hash_pyxhash_chash_cpprK   s         r   _test_options_invalidationz&TestCyCache._test_options_invalidation   sO   7<<m<<-CKK<-(4/Mc&kk\M*V3(C   	AGGFOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	84>GGGGC 0 0 > >??@@@
	&84>FFFFC 0 0 > >??@@@	 If  	  	  	 Ih	  	84>UZ[[[[C 0 0 > >??@@@
	&84>UYZZZZC 0 0 > >??@@@@@s$   ,BBB E E65E6c                 :    |                      | j                   d S r   )r   r*   r   s    r   #test_options_invalidation_cythonizez/TestCyCache.test_options_invalidation_cythonize   s    ''(<=====r   c                 :    |                      | j                   d S r   )r   r/   r   s    r   !test_options_invalidation_compilez-TestCyCache.test_options_invalidation_compile   s    ''(:;;;;;r   N)__name__
__module____qualname__r   r   r*   r/   rO   rQ   rS   r]   r_   rb   rk   rm   ro   ru   rw   ry   r   r   r    r   r   r   r      sA       M M MB B B= = =
6 6 6
(I (I (IT8 8 86 6 6J J J*< < <: : :8 8 8< < <: : :< < <(; ; ;9 9 9A A A>> > >< < < < <r   r   )rC   r   rY   r   sysr   unittestCython.Build.Dependenciesr    Cython.Compiler.MainCython.UtilsCython.TestUtilsr   r   r   r   r   <module>r      s       				 



                   ' ' ' ' ' 's< s< s< s< s<* s< s< s< s< s<r   