
    xKg0                         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 d dl	Z	d dl
Z
	 d dlZdZ	 d dlZdZ G d de	j                         Zedk(  r e	j$                          yy# e$ r dZY =w xY w# e$ r dZY Cw xY w)    N)cudaTFc                   2   e Zd ZdZdddZd Zd Zd Zd Zd	 Z	d
 Z
d Z ej                   ej                          d      d        Zd Zd Zd Zd Zd Zd Z ej.                  ed      d        Z ej.                  ed      d        Zd Zd Zd Zy)TestCasezThese test cases are meant to test the Numba test infrastructure itself.
    Therefore, the logic used here shouldn't use numba.testing, but only the
    upstream unittest, and run the numba test suite only in a subprocess.Nsubp_kwargsc                   |xs i }t         j                  dddgt        |      z   }t        j                  |fi |}|j                  d      j                         }|D cg c]  }|j                         s| }}|S c c}w )zX
        Use `subp_kwargs` to pass extra argument to `subprocess.check_output`.
        -mnumba.runtestsz-lUTF-8)sys
executablelist
subprocesscheck_outputdecode
splitlinesstrip)selfargsr   cmd	out_byteslineslines          ]/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/tests/test_runtests.pyget_testsuite_listingzTestCase.get_testsuite_listing!   s~     "'R~~t%5t<tDzI++C?;?	  )446"'8%$4::<%8 9s    A>6A>c                     | j                  |g      }|d d D ]6  }dj                  ||      }| j                  |j                  |      |       8 y )Nz{!r} not startswith {!r})msg)r   format
assertTrue
startswith)r   prefixlistinglnerrmsgs        r   check_listing_prefixzTestCase.check_listing_prefix,   sO    ,,fX6#2,B/66r6BFOOBMM&1vO>     c                    | j                  |      }|d   }| j                  d|v        t        |j                  d      d         }| j	                  t        |      t        |dz   |dz                | j                  ||       |S )zR
        Check that the reported numbers of tests are at least *minsize*.
        r   tests found r         )r   r    intsplitassertInlenrangeassertGreaterEqual)r   r   minsizer   	last_linenumbers         r   check_testsuite_sizezTestCase.check_testsuite_size2   s~     **40"I	23Y__S)!,- 	c%j%
FRK"@A0r'   c                     | j                  |d      }| j                  t        d |D                     | j                  t        d |D                     y )Ni  c              3   $   K   | ]  }d |v  
 yw)znumba.cuda.tests.N .0r   s     r   	<genexpr>z%TestCase.check_all.<locals>.<genexpr>C   s     JED/47E   c              3   $   K   | ]  }d |v  
 yw)znumba.tests.npyufunc.test_Nr9   r:   s     r   r<   z%TestCase.check_all.<locals>.<genexpr>E   s      /(- 9D@(-r=   )r6   r    any)r   idsr   s      r   	check_allzTestCase.check_all@   sK    ))#t4JEJJK /(-/ / 	1r'   c                     t        d |      S )z|returns a filter on strings starting with 'numba.', useful for
        selecting the 'numba' test names from a test listing.c                 $    | j                  d      S )Nznumba.)r!   )xs    r   <lambda>z8TestCase._get_numba_tests_from_listing.<locals>.<lambda>K   s    X 6r'   )filter)r   r#   s     r   _get_numba_tests_from_listingz&TestCase._get_numba_tests_from_listingH   s     6@@r'   c                 &    | j                  g        y )NrA   r   s    r   test_defaultzTestCase.test_defaultM   s    rr'   c                 (    | j                  dg       y )Nnumba.testsrI   rJ   s    r   test_allzTestCase.test_allP   s    'r'   c                 Z    t        j                         rdnd}| j                  dg|       y )Nd   r+   znumba.cuda.tests)r   is_availabler6   )r   r3   s     r   	test_cudazTestCase.test_cudaS   s*     **,#!!!#5"6@r'   zNO CUDAc                     | j                  d       | j                  d       | j                  d       | j                  d       y )Nznumba.cuda.tests.cudadrvznumba.cuda.tests.cudapyznumba.cuda.tests.nocudaznumba.cuda.tests.cudasim)r&   rJ   s    r   test_cuda_submoduleszTestCase.test_cuda_submodulesY   s>    !!"<=!!";<!!";<!!"<=r'   c                 x    | j                  dgd       | j                  dgd       | j                  ddgd       y )Nznumba.tests.test_storeslice   znumba.tests.test_nested_calls
      r6   rJ   s    r   test_modulezTestCase.test_module`   sH    !!#@"A1E!!#B"CRH!!#B#@#BCE	Gr'   c                 *    | j                  dgd       y )Nnumba.tests.npyufunc2   rY   rJ   s    r   test_subpackagezTestCase.test_subpackageg   s    !!#9":B?r'   c                 ,    | j                  g dd       y )N)z--randomz0.1r\      rY   rJ   s    r   test_randomzTestCase.test_randomj   s    !!7	<r'   c                       fd}ddg} |dg      }|D ]\  } |d|dg      } |d|dg      } j                  |||z           |d|z  dg      } |d|z  dg      } j                  |||z          ^ y )	Nc                     j                  |       }j                  d|d          t        |d   j                         d         }j	                  |dkD         |S )Nr)   r   r   )r   r/   r-   r.   r    )arg_listr   countr   s      r   	get_countz5TestCase.test_include_exclude_tags.<locals>.get_counto   sT    ..x8EMM-r3b	)!,-EOOEAI&Lr'   long_runningzlong_running, importantrM   z--tagsz--exclude-tagsz	--tags=%sz--exclude-tags=%s)assertEqual)r   rf   tagstotaltagincludedexcludeds   `      r   test_include_exclude_tagsz"TestCase.test_include_exclude_tagsn   s    	  9:=/*C (C!?@H "2C!GHHUHx$78 !+"3]!CDH "5";]!KLHUHx$78 r'   c                    | j                  g       }| j                  ddg      }| j                  ddg      }t        | j                  |            }t        | j                  |            }t        | j                  |            }| j                  t	        t        |      t        |      z
        t        |      dz         | j                  t        |      t        |             | j                  t        |      t        |             y )N-jz0:2z1:2r,   )r   setrG   
assertLessabsr0   )r   tmpAlltmp1tmp2lAlll1l2s          r   test_check_shardzTestCase.test_check_shard   s    ++B/))4-8))4-8455f=>33D9:33D9: 	CGc"g-.D	B?BT+BT+r'   c                    t               }t        d      D ]H  }| j                  ddj                  |      g      }g | j	                  |      }|j                  |       J | j                  ddg      }t        | j	                  |            }| j                  t        |      d       |D cg c]  }t        |       }}t        t        |            D ],  }| j                  t        ||         t        ||                . |D ]>  }	|D ]7  }
| j                  |
|	       |	j                  |
       | j                  |
|	       9 @ t        j                  |d      D ]  \  }}| j                  ||z          t               }|D ]  }|j!                  |        |j!                  |       t        | j	                  | j                  g                   }| j                  ||       y c c}w )N   rp   z{}:3z--tagalways_testr+   rV   )r   r1   r   r   rG   appendrq   r2   r0   rh   r/   removeassertNotIn	itertoolscombinationsassertFalseupdate)r   shardedisubsetslisttmpalways_runningrD   sharded_setsshardtestabsum_of_partsfull_listings                  r   test_check_sharding_equivalentz'TestCase.test_check_sharding_equivalent   s   &qA//v}}Q7G0HIFAd88@AENN5!  (('=)ABT??DE 	N 3Q7 )001A0s7|$ASa13wqz?C %
 "E&dE*T"  u- ' " **<;DAqQU# < uA" N+4==&&r*, - 	|47 1s   -G(zRequires gitpythonc                    	 t        j                  dt         j                  t         j                         | j                  dg      }| j                  d|       | j                  dg      }| j                  d|       t        t         j                        }| j                  t         j                        5  | j                  dg|	       d d d        y # t        $ r | j	                  d       Y w xY w# 1 sw Y   y xY w)
Ngitstdoutstderrzno git availablez-gzGit diff by common ancestorz-g=ancestor)r   z	-g=ancestr   )r   callDEVNULLFileNotFoundErrorskipTestr   r   r/   dictassertRaisesCalledProcessError)r   outsr   s      r   test_gitdiffzTestCase.test_gitdiff   s    	.OOE#-#5#5#-#5#57 ))4&16=))=/:3T:*"4"45z<<=&&}+&N >= ! 	.MM,-	. >=s   4C 7C5C21C25C>zRequires pyyamlc                 Z   ddl m} t        j                  j	                  t        j                  j                  t                    }t        j                  j                  |ddd      }t        j                  j                  |      s| j                  d       t        t        j                  j                  |      d      5 }|j                         }d d d        t        j                  |      }|d   }g }|d d D ]3  }	|	d	   d
   }
|
j                         D ]  }|j                  |d           5 g d}t        j                  j                  |g| }t        j                  j                  |      s| j                  d       t        t        j                  j                  |      d      5 }|j                         }d d d        t        j                  ||      }|d   d   d   d
   }
|
j                         D ]  }|j                  |d           | j                  t!        |      t!        t#        |                   t%        |      dz   }g t'        |      }| j                  t)        |      |       | j                  ||d   d          y # 1 sw Y   xY w# 1 sw Y   xY w)Nr   )Loader..zazure-pipelines.ymlz&'azure-pipelines.yml' is not availablertjobsrV   
parametersmatrixTEST_START_INDEX)r   r   buildscriptsazurezazure-windows.ymlz$'azure-windows.yml' is not availablestrategyr+   	variables
TEST_COUNT)yamlr   ospathdirnameabspath__file__joinisfiler   openreadloadvaluesr~   rh   r0   rq   maxr1   sorted)r   r   	base_path
azure_pipefdatapipe_yml	templatesstart_indexestmpltr   setupwinpathazure_windowswindows_ymllim_start_indexexpecteds                    r   test_azure_configzTestCase.test_azure_config   s   GGOOBGGOOH$=>	WW\\)T49NO
ww~~j)MMBC"''//*-t4668D 599T&1V$	r]E<(2F$$U+=%>? ) # MY99ww~~m,MM@A"''//-0$71668D 8iiV4 V$Q'
3H=]]_E  '9!:; %
 	]+S]1C-DEm,q0,U?+,.9(;*?*MNG 54" 87s   J1J!J!J*c                    d}| j                  t        j                        5 }t        j                  d|j                  d      g}t        j                  |t        j                  d       d d d        | j                  dj                  j                  j                  d             t        j                  d|j                  d      g}t        j                  |t        j                  t        j                  	       y # 1 sw Y   xY w)
NaJ  if 1:
        from unittest import mock
        from llvmlite import binding as llvm
        error = RuntimeError("Detected compilation during test listing")
        with mock.patch.object(llvm.ExecutionEngine, 'finalize_object',
                               side_effect=error):
            import numba
            {0}
        z-cznumba.njit(lambda:0)()<   )r   timeoutz(Detected compilation during test listingr   znumba.test('-l')r   )r   r   r   r   r   r   r   STDOUTr/   	exceptionr   r   
check_callr   )r   coderaisesr   s       r   test_no_compilation_on_listz$TestCase.test_no_compilation_on_list  s     z<<=>>45M)NOC##C+5+<+<,.0 >
 	@&&--44W=	?
 ~~tT[[1C%DEc%/%7%7%/%7%7	: >=s   A	C??Dc                    t         j                  dddddg}t        j                  |dt        j                        }| j                  t        j                  d|             | j                  t        j                  d	|             y )
Nr	   r
   z--show-timing-vm11numba.tests.test_usecases.TestUsecases.test_sum1dutf8encodingr   zRuntime \(seconds\): \d*\.\d*z(Total test runtime \(seconds\): \d*\.\d*)r   r   r   r   r   assertIsNotNoneresearch)r   r   outs      r   test_show_timingzTestCase.test_show_timing  sw    ~~t%5BD%%cF-7->->@II6<	
 	IIA3G	
r'   c                    t         j                  dddddg}t        j                  |dt        j                        }t        j                  d|      }|j                  d	      }| j                  t        j                  |      j                                t        j                  j                  j                  |       y )
Nr	   r
   z--junitr   r   r   r   z2Writing junit xml file: (junit_numba_[0-9_-]+.xml)r+   )r   r   r   r   r   r   r   groupr    pathlibPathexistsxmletreeElementTreeparse)r   r   r   mxml_filepaths        r   test_junit_outputzTestCase.test_junit_output*  s    ~~t%5y&BD%%cF-7->->@IIKwwqz\299;<		##L1r'   )__name__
__module____qualname____doc__r   r&   r6   rA   rG   rK   rN   rR   unittestskipIfr   rQ   rT   rZ   r^   ra   rn   rz   r   
skipUnlesshas_gitpythonr   
has_pyyamlr   r   r   r   r9   r'   r   r   r      s    M :> 	?1A
(A X__***,,i8> 9>G@<9,,+5Z X(<=O >O( X%67)O 8)OV::


2r'   r   __main__)r   r   r   r   r   xml.etree.ElementTreer   numbar   r   r   r   r   ImportErrorr   r   r   r   mainr9   r'   r   <module>r      s    	 
  	      M JX2x   X2v zHMMO Q	  M  Js"   A" A/ "A,+A,/A98A9