
    yIf                        d Z ddlmZ ddlZddlZddlmZmZmZ ddl	m
Z
mZ ddlmZmZ ddlmZ erddlmZ dd	lmZ dd
lmZ ddlmZ  ej        e          Z G d de          Zd$dZd%dZd&dZd'd"Z d#Z!dS )(z,Defines how to run a single tox environment.    )annotationsN)TYPE_CHECKING
NamedTuplecast)OutcomeStdinSource)FailSkip)ToxBackendFailed)Path)Command)ToxEnv)	RunToxEnvc                  P    e Zd ZU ded<   ded<   ded<   ded<   d	ed
<   dZded<   dS )ToxEnvRunResultstrnameboolskippedintcodelist[Outcome]outcomesfloatdurationFignore_outcomeN)__name__
__module____qualname____annotations__r        N/var/www/piapp/venv/lib/python3.11/site-packages/tox/session/cmd/run/single.pyr   r      sS         IIIMMMIIIOOO N      r"   r   tox_envr   no_testr   suspend_displayreturnc           	     ,   t          j                    }| j        j        }|                     |          5  t          | |          \  }}}d d d            n# 1 swxY w Y   t          j                    |z
  }t          |||||| j        d                   S )Nr   )time	monotonicconfr   display_context	_evaluater   )	r$   r%   r&   	start_oner   r   r   r   r   s	            r#   run_oner/       s      I<D		 	 	1	1 > >"+GW"="=x> > > > > > > > > > > > > > >~)+H4$(GLQaDbcccs   AAAtuple[bool, int, list[Outcome]]c                   d}d}g }	 	 |                                   t          | |          \  }}n# t          $ r)}t                              d|           d}d}Y d }~nd }~wt
          $ r4}t                              d|           t          |j                  d }~wt          $ r'}t                              d|           d}Y d }~n/d }~wt          $ r t                              d           d	}Y nw xY w|                                  n# |                                  w xY wn1# t          $ r$}t          t          |j                  }Y d }~nd }~ww xY w|||fS )
NFr   zskipped because %sTz%szfailed with %s   zinternal error   )setuprun_commandsr
   LOGGERwarningr   error
SystemExitr   r	   	Exception	exceptionteardownr   r   )r$   r%   r   r   r   r;   s         r#   r-   r-   )   s   GD H)	MMOOO)'7;;ND(( 	 	 	NN/;;;DGGGGGG 	- 	- 	-LLy)))Y^,,, 	 	 	LL)9555DDDDDD 	 	 	-...DDD	 G ) ) )C(()D(""ss   '1 D 
C6AD C6,/BC6(C
D 
)C63D 5C66D 9D( D$$D( (
E2EEtuple[int, list[Outcome]]c           	     :   g }|rt           j        }nddlm} | j        d         }|                    dd           | j        d         }|                    |            d\  }}}		 	 t          | d|||          }|t           j        k    s|rt          | d	|||          }nt           j        }t          | d
|||          }	n# t          | d
|||          }	w xY w	 |p|p|	}|                    | ||           n"# |p|p|	}|                    | ||           w xY w||fS )Nr   )MANAGER
change_dirT)exist_okparentsignore_errors)rD   rD   commands_precommandscommands_post)	r   OKtox.plugin.managerr?   r+   mkdirtox_before_run_commandsrun_command_settox_after_run_commands)
r$   r%   r   	exit_coder?   chdirrC   
status_prestatus_mainstatus_posts
             r#   r5   r5   E   sm    H IJ		......l<0T4000%l?;''000/9,
K	Ih,Wne]\dee
++}+"1':um]e"f"fKK")*K-g}^fggog}^fgggggg"@k@[I**7IxHHHH #@k@[I**7IxHHHHhs   'AC  ,C7  CC7 7Dr   keyr   cwdr   rC   r   r   r   c                d   t           j        }| j        |         }t          |          D ]\  }}|                     |j        |t          j                    d| d| d          }	|                    |	           	 |j	        r|	
                                 n|	                                 # t          $ rw}
|j        rt          j        d           Y d }
~
|r/|t           j        k    rt!          t"          |
j                  }Y d }
~
t!          t"          |
j                  cY d }
~
c S d }
~
ww xY w|S )NT[])rT   stdinshowrun_idzEcommand failed but is marked ignore outcome so handling it as success)r   rH   r+   	enumerateexecuteargsr   	user_onlyappendinvert_exit_codeassert_failureassert_successr9   ignore_exit_codeloggingr7   r   r   r   )r$   rS   rT   rC   r   rN   command_setatcmdcurrent_outcomer;   s              r#   rL   rL   `   sb    
I!(c!2K[)) - -C!//H'))>>B>>> * 
 
 	(((	-# 1..0000..000 	- 	- 	-#  ghhh 
** $S). 9 9IY^,,,,,,,,,,	- s*   ;0B,,
D-6D(,D(D( D-(D-)r   rL   r/   )r$   r   r%   r   r&   r   r'   r   )r$   r   r%   r   r'   r0   )r$   r   r%   r   r'   r=   )r$   r   rS   r   rT   r   rC   r   r   r   r'   r   )"__doc__
__future__r   rd   r)   typingr   r   r   tox.execute.apir   r   tox.tox_env.errorsr	   r
   0tox.tox_env.python.virtual_env.package.pyprojectr   pathlibr   tox.config.typesr   tox.tox_env.apir   tox.tox_env.runnerr   	getLoggerr   r6   r   r/   r-   r5   rL   __all__r!   r"   r#   <module>ru      s{   2 2 " " " " " "   2 2 2 2 2 2 2 2 2 2 0 0 0 0 0 0 0 0 ) ) ) ) ) ) ) ) M M M M M M -((((((&&&&&&,,,,,,		8	$	$! ! ! ! !j ! ! !d d d d# # # #8   6       Fr"   