
    hht                         d dl Z d dlZd dlmZ d dlmZmZmZm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y)    N)__version__)
controllerviews	operatorsutilsc                 .    t               }t        |       y N)build_parser	run_mutpy)argvparsers     /home/xtuchyna/.var/app/com.visualstudio.code/data/virtualenvs/gen-test-bench-v8TMe8KL/lib/python3.12/site-packages/mutpy/commandline.pymainr      s    ^Ff    c            	      ^   d} t        j                  dd      }|j                  ddddj                  t              	       |j                  d
dt
        dd       |j                  ddt
        dd       |j                  dt
        ddgddd       |j                  ddt
        dd       |j                  dt
        dd       |j                  d d!t        | d"j                  |       #       |j                  d$d%d&d'(       |j                  d)d*d&d+(       |j                  d,d&d-(       |j                  d.d/d&d0(       |j                  d1d2d&d3(       |j                  d4d5d&d6(       |j                  d7d8t
        dd9d:;       |j                  d<t
        dg d=d:>       |j                  d?d@d&dA(       |j                  dBdCt
        dDdEF       |j                  dGt        dHdIdJK       |j                  dLd&dM(       |j                  dNt        dOdPdQK       |j                  dRt
        dSdTdUV       |j                  dWd&dX(       |j                  dYt        dZd[F       |j                  d\d]t
        dD^       |j                  d_d`t        dadbc       |j                  dddedft        dg       |S )hN   z2Mutation testing tool for Python 3.x source code. @)descriptionfromfile_prefix_charsz	--versionz-vversionz%(prog)s {})actionr   z--targetz-t+z"target module or package to mutate)typenargshelpz--unit-testz-uz:test class, test method, module or package with unit testsz--runnerunittestpytestRUNNERztest runner)r   choicesdefaultmetavarr   z--reportz-rzgenerate YAML reportREPORT_FILE)r   r   r!   z--report-htmlzgenerate HTML reportDIR_NAMEz--timeout-factorz-fzmax timeout factor (default {}))r   r    r   z--show-mutantsz-m
store_truezshow mutants source code)r   r   z--quietz-qz
quiet modez--debugz
dubug modez--colored-outputz-cztry print colored outputz--disable-stdoutz-dzftry disable stdout during mutation (this option can damage your tests if you interact with sys.stdout)z--experimental-operatorsz-ezuse experimental operatorsz
--operatorz-ozuse only selected operatorsOPERATOR)r   r   r   r!   z--disable-operatorzdisable selected operators)r   r   r    r   r!   z--list-operatorsz-lzlist available operatorsz--pathz-pDIRzextend Python path)r   r!   r   z--percentage
PERCENTAGEd   z7percentage of the generated mutants (mutation sampling))r   r!   r    r   z
--coveragezmutate only covered codez--orderORDER   zmutation orderz--hom-strategyHOM_STRATEGYzHOM strategyFIRST_TO_LAST)r   r!   r   r    z--list-hom-strategieszlist available HOM strategiesz--mutation-numberMUTATION_NUMBERz%run only one mutation (debug purpose)z--eda-folderz<save results to this folder under csv files for EDA analysis)r   r   r!   z--theta-factorz:Comparison thereshold for Mutation Testing of failed testsFLOATg?)r   r   r!   r    z--rapfd-factorz#Testing contraint m for RAPFD scoreINTEGER)r   r!   r   r    )argparseArgumentParseradd_argumentformatr   strfloatint)DEF_TIMEOUT_FACTORr   s     r   r
   r
      s    $$1e;>@F
T)]EYEYZaEbc

Ds#Dhi
t#SY  [

z86LV` (}  >

Ds9OYfg
c8NXbc
*DuFX>EEFXY  [
($|Jde
	4<P
	,\J
*DLfg
*Dc  d 2DTpq
dC:J  P
,3c29:  O
*DLfg
$S%FZ[
S,PSV  X
\7  9
	WaN^_
(sNQ_ /  1
/Kjk
+#?PD  F
-k %  1
(/k"GS  B
(/T )Q  @Mr   c                 X   | j                         }|j                  rt                y |j                  rt                y |j                  rP|j                  rDt        |      }|j                          |j                  r|j                  |j                         y y | j                          y r	   )

parse_argslist_operatorslist_hom_strategiestarget	unit_testbuild_controllerrun
eda_foldersave_edaprint_usage)r   cfgmutation_controllers      r   r   r   <   s~    



C
		 	 	.s3!>>((8  	r   c                    t        | j                        }t        |       }t        |       }t	        j
                  | j                  | j                        }t	        j
                  | j                  | j                        }t        j                  |||||| j                  | j                  | j                  | j                  | j                  | j                         S )N)
runner_clstarget_loadertest_loaderr   mutant_generatortimeout_factordisable_stdoutmutate_coveredmutation_numbertheta_factorrapfd_constraint_m)get_runner_clsrunnerbuild_viewsbuild_mutatorr   ModulesLoaderr<   pathr=   r   MutationControllerrJ   rK   coveragerM   rN   rapfd_factor)rC   rF   built_viewsrI   rG   rH   s         r   r>   r>   M   s    

+Jc"K$S)''

CHH=M%%cmmSXX>K((#)))))||++%%++ r   c                 j    | dk(  rddl m} |S | dk(  rddl m} |S t        dj	                  |             )Nr   r   )UnittestTestRunnerr   )PytestTestRunnerzUnknown runner: {0})mutpy.test_runnersr[   r\   
ValueErrorr3   )rQ   r[   r\   s      r   rP   rP   b   s;    9!!	8	7
*11&9
::r   c                    t               }| j                  r|t        j                  z  }t               }| j                  r(|| j                  D ch c]  }t        ||       c}z  }n|t        j                  z  }|| j                  D ch c]  }t        ||       c}z  }| j                  dk(  r t        j                  || j                        S t        |       }t        j                  || j                  |      S c c}w c c}w )Nr*   )hom_strategy)setexperimental_operatorsr   build_name_to_operator_mapoperatorget_operatorstandard_operatorsdisable_operatororderr   FirstOrderMutator
percentagebuild_hom_strategyHighOrderMutator)rC   operators_setname_to_operatornamer`   s        r   rS   rS   l   s    EM
!!99913
||&)ll4&2d 't-=>&24 	4 	555"%"6"68"6$ #4)9:"68 8M yyA~++M3>>JJ)#.**=#..Wcdd4
8s   C>
Dc                    | j                   dk  r t        d       t        j                  d       	 t        j
                  D ci c]  }|j                  | }} || j                     | j                         S c c}w # t        $ r< t        dj                  | j                               t        j                  d       Y y w xY w)Nr*   zOrder should be > 0.)rh   zJUnsupported HOM strategy {}! Use --list-hom-strategies to show strategies.)
rh   printsysexitr   hom_strategiesro   r`   KeyErrorr3   )rC   r`   name_to_hom_strategys      r   rk   rk      s    
yy1}$%T^TmTmnTmL 1 1< ?Tmn5#C$4$45CIIFF  o Zaabebrbrsts$   A> A9!A> 9A> >ACCc                     	 ||    S # t         $ r2 t        dj                  |              t        j                  d       Y y w xY w)Nz6Unsupported operator {}! Use -l to show all operators.rq   )rv   rr   r3   rs   rt   )ro   rn   s     r   re   re      s@    %% FMMdSTs    8AAc                      i } t         j                  t         j                  z  D ](  }|| |j                         <   || |j	                         <   * | S r	   )r   rf   rb   ro   	long_name)resultrd   s     r   rc   rc      sM    F0093S3SS"*x}}'/x!!#$ T Mr   c                 8   g }| j                   r/|j                  t        j                  | j                               n9|j                  t        j
                  | j                  | j                               | j                  r.|j                  t        j                  | j                               | j                  r.|j                  t        j                  | j                               | j                  r#|j                  t        j                                |S r	   )quietappendr   QuietTextViewcolored_outputTextViewshow_mutantsreportYAMLReportViewreport_htmlHTMLReportViewdebug	DebugView)rC   
views_lists     r   rR   rR      s    J
yy%--c.@.@AB%..););S=M=MNO
zz%..szz:;
%..s?@
yy%//+,r   c                     t        d       t        j                  t        j                        D ]9  } t        dj                  | j                         | j                                      ; t        d       t        j                  t        j                        D ]9  } t        dj                  | j                         | j                                      ; y )NzStandard mutation operators:z - {:3} - {}z Experimental mutation operators:)	rr   r   sort_operatorsr   rf   r3   ro   rz   rb   )rd   s    r   r:   r:      s    	
()(()E)EFn##HMMOX5G5G5IJK G	
,-(()I)IJn##HMMOX5G5G5IJK Kr   c                      t        d       t        j                  D ]&  } t        dj                  | j                               ( y )NzHOM strategies:z - {})rr   r   ru   r3   ro   )strategys    r   r;   r;      s0    	
--gnnX]]+, .r   )r0   rs   mutpyr   r   r   r   r   r   r   r
   r   r>   rP   rS   rk   re   rc   rR   r:   r;    r   r   <module>r      sS     
 ( 5 5
,^"*;e0	(L-r   