3 F\ @sdZddlmZddlZddlZddlZddlZddlZeje Z Gdddej Z Gdddej Z yddlmZd Ze ZWnek rd Ze ZYnXdS) asetuptools/distutils command to run testr via setup.py PBR will hook in the Testr class to provide "setup.py test" when .testr.conf is present in the repository (see pbr/hooks/commands.py). If we are activated but testrepository is not installed, we provide a sensible error. You can pass --coverage which will also export PYTHON='coverage run --source ' and automatically combine the coverage from each testr backend test runner after the run completes. )cmdNc @s\eZdZdZd!d"d#d$d%d&d'gZdd dgZddZddZddZddZ ddZ dd Z dS)( TestrRealz&DEPRECATED: Run unit tests using testrcoverageNGReplace PYTHON with coverage and merge coverage from each testr worker. testr-args=tRun 'testr' with these argsomit=o(Files to omit from coverage calculationscoverage-package-name=LUse this name to select packages for coverage (one or more, comma-separated)slowest-Show slowest test times after tests complete. no-parallelRun testr serially log-level=lLog level (default: info) no_parallelcGs2tjd|tjtjdgt|tjtjtj S)Nz _run_testr called with args = %rr) loggerdebugcommandsZrun_argvsysargvliststdinstdoutstderr)selfargsr!f/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/pbr/pbr/testr_command.py _run_testrHs zTestrReal._run_testrcCs.d|_d|_d|_d|_d|_d|_d|_dS)Ninfo) testr_argsromitrcoverage_package_namer log_level)rr!r!r"initialize_optionsMszTestrReal.initialize_optionscCsptt|jjtj|_tj|jdtjd|jdkr@g|_n |jj |_|j r^d|j |_ tjd|j dS)N)levelzfinalize_options calledz --omit=%sz$finalize_options: self.__dict__ = %r) getattrloggingr)upperINFO basicConfigrrr&splitr'__dict__)rr!r!r"finalize_optionsVs     zTestrReal.finalize_optionscCstjdtjdttjjds,|jd|j r:|j |j sR|jd |j }n|jd |j }|rvt jjd||jrtd|jd |j r|jd S) z"Set up testr repo, then run testr.z run calledzctestr integration in pbr is deprecated. Please use the 'testr' setup command or call testr directlyz.testrepositoryinitrun --parallelztestr failed (%d)z Slowest TestsrN)r5r6)r5)rrwarningswarnDeprecationWarningospathisdirr#r_coverage_beforerr& distutilserrorsDistutilsErrorrprint_coverage_after)rZ testr_retr!r!r"r5es$     z TestrReal.runcCsbtjd|jj}|jdr*|dd}|jr6|j}d|}d|tjd<tjdtjddS)Nz_coverage_before calledzpython-z--source %s --parallel-modezcoverage run %sPYTHONzos.environ['PYTHON'] = %r)rr distributionget_name startswithr(r:environ)rpackageoptionsr!r!r"r=s    zTestrReal._coverage_beforecCs8tjdtjdtjd|jtjd|jdS)Nz_coverage_after calledzcoverage combinezcoverage html -d ./cover %sz'coverage xml -o ./cover/coverage.xml %s)rrr:systemr')rr!r!r"rBs  zTestrReal._coverage_after)rNr)rrr)r r r )r Nr )rNr)rNr)rrr) __name__ __module__ __qualname__ description user_optionsboolean_optionsr#r*r3r5r=rBr!r!r!r"r5s   rc@s,eZdZdZgZddZddZddZdS) TestrFakezRun unit tests using testrcCsdS)Nr!)rr!r!r"r*szTestrFake.initialize_optionscCsdS)Nr!)rr!r!r"r3szTestrFake.finalize_optionscCs tddS)Nz7Install testrepository to run 'testr' command properly.)rA)rr!r!r"r5sz TestrFake.runN)rLrMrNrOrPr*r3r5r!r!r!r"rRs rR)rTF)__doc__r>rdistutils.errorsr-r:rr7 getLoggerrLrCommandrrRZtestrepositoryrZ have_testrZTestr ImportErrorr!r!r!r")s   ^