
    $+h                     \    d Z ddlZddlZddlZddZdZdZd Zd Zd Z	d	 Z
d
 ZddZd Zy)z4Common utilities in testing the modified MutPy fork.    Nc                     t         j                  t         j                  z   }dj                  t	        j
                  ||             S )z3Generate for the purpose of observing killed mutant )k)stringascii_lettersdigitsjoinrandomchoices)length
characterss     U/home/xtuchyna/git/gen-test-bench-simulation/reference_data/test_data/rapfd/common.pygenerate_random_stringr      s0    %%5J776>>*788    ztest_call_count.csv   c                      t         j                  j                  t              s+t	        t        d      5 } | j                  d       ddd       yy# 1 sw Y   yxY w)z7Initialize the counter file with 0 if it doesn't exist.w0N)ospathexistscounter_fileopenwritefiles    r   initialize_counterr      s=    77>>,',$JJsO %$ ($$s   AAc                  $   t        t        d      5 } t        | j                         j	                               }ddd       dz  }t        t        d      5 } | j                  t        |             ddd       y# 1 sw Y   BxY w# 1 sw Y   yxY w)z:Increment the counter value and write it back to the file.rN   r   )r   r   intreadstripr   str)r   counts     r   increment_counterr&      sk    	lC	 DDIIK%%'( 
!	QJE	lC	 D

3u: 
!	  
!	  
!	 s   (A:B:BBc                      t        t        d      5 } t        | j                         j	                               cddd       S # 1 sw Y   yxY w)z*Read and return the current counter value.r   N)r   r   r!   r"   r#   r   s    r   get_counterr(      s1    	lC	 D499;$$&' 
!	 	 s   'AAc                  p    t        t        d      5 } | j                  d       ddd       y# 1 sw Y   yxY w)zReset the counter value to 0.r   r   N)r   r   r   r   s    r   reset_counterr*   #   s%    	lC	 D

3 
!	 	 s   ,5c                      t         j                  j                  t              r-t        j                  t               t        dt         d       yt        dt         d       y)z%Delete the counter file if it exists.zCounter file 'z' has been deleted.z' does not exist.N)r   r   r   r   removeprint r   r   delete_counterr/   (   sB    	ww~~l#
		,|n,?@A|n,=>?r   c                 Z    t                t               }|t        dz   k(  rt                y y )Nr    )r&   r(   overall_faultsr/   )is_rapfdfuture_counts     r   last_test_routiner4   1   s'    =L~)) *r   c                 2    | |v rt        t                     y)z}Simulate run for mutant number <call_count>.
    Detect failure if this mutant is identified from <fault_ids_to_detect>.
    N)	Exceptionr   )
call_countfault_ids_to_detects     r   simulate_test_case_runr9   9   s     ((.011r   )d   )F)__doc__r
   r   r   r   r   r1   r   r&   r(   r*   r/   r4   r9   r.   r   r   <module>r<      sF    :   	9
 %(

@r   