+
    Dfje8                     ~   R t ^ RIt^ RIHtHtHtHtHtHtH	t	H
t
 ^ RIHt ^ RIHt ^ RIHt ^ RIHtHt ^ RIHtHt ^ RIHt ^ R	IHtHt ^ R
IHt ^ RIHt ^ RIH t  ^ RI!H"t" ^ RI#H$t$ ^ RI%H&t& ^ RI'H(t(H)t)H*t*H+t+ ^ RI,H-t- ^ RI.H/t/ ^ RI0H1t1H2t2 ^ RI3H4t4 ^RI5H6t6H7t7H8t8 ]! RR7       ! R R]94      4       t: ! R R]4      t; ! R R]4      t<]
! R4      t=]]<.]]=,          3,          t> ! R R ] 4      t? ! R! R"] 4      t@]! ]4       ! R# R$4      4       tA]! ]4       ! R% R&4      4       tB ! R' R(]94      tC ! R) R*]4      tDR# )+z:
This module implements the worker classes.

@since: 12.3
N)Any	AwaitableCallableDictListOptionalTextIOTypeVar)TestCase)implementer)frozen)Protocol	TypedDict)DeferredDeferredList)ProcessDone)IAddress
ITransport)ProcessProtocol)Logger)AMPFailure)FilePath)namedObject)_WORKER_AMP_STDIN_WORKER_AMP_STDOUTmanagercommandsworkercommands)WorkerReporter)
TestResult)
TestLoader
TrialSuite)Todo)
StreamOpenStreamReceiverStreamWriteF)auto_excc                   0   a  ] tR t^+t o RtV 3R ltRtV tR# )WorkerExceptionz}
An exception was reported by a test running in a worker process.

@ivar message: An error message describing the exception.
c                &   < V ^8  d   Qh/ S[ ;R&   # )   message)str)format__classdict__s   "</usr/lib/python3/dist-packages/twisted/trial/_dist/worker.py__annotate__WorkerException.__annotate__+   s      L      N__name__
__module____qualname____firstlineno____doc____annotate_func____static_attributes____classdictcell__r/   s   @r0   r)   r)   +   s       r3   r)   c                   0   a  ] tR t^6t o RtV 3R ltRtV tR# )	RunResultz:
Represent the result of a L{workercommands.Run} command.
c                &   < V ^8  d   Qh/ S[ ;R&   # )r+   success)bool)r.   r/   s   "r0   r1   RunResult.__annotate__6   s     
 M r3   r4   Nr5   r>   s   @r0   r@   r@   6   s       r3   r@   c                   6   a  ] tR t^>t o RtV 3R lR ltRtV tR# )Workerz!
An object that can run actions.
c                ,   < V ^8  d   QhRS[ RS[RS[/# )r+   caseresultreturnr
   r    r@   )r.   r/   s   "r0   r1   Worker.__annotate__C   s"      h 
 y r3   c                   "   R# 5i)z
Run a test case.
Nr4   )selfrH   rI   s   &&&r0   run
Worker.runC   s     s   r4   N)r6   r7   r8   r9   r:   rO   r<   r=   r>   s   @r0   rF   rF   >   s      r3   rF   _Tc                      a  ] tR t^Mt o Rt]! 4       tRR lt]P                  P                  V 3R lR l4       t]P                  P                  R 4       tRtV tR# )	WorkerProtocolz-
The worker-side trial distributed protocol.
c                P    \        4       V n        \        V 4      V n        Wn        R # N)r!   _loaderr   _result_forceGarbageCollection)rN   forceGarbageCollections   &&r0   __init__WorkerProtocol.__init__T   s    !|%d+'=$r3   c                &   < V ^8  d   QhRS[ RS[/# )r+   testCaserJ   )r-   r@   )r.   r/   s   "r0   r1   WorkerProtocol.__annotate__Z   s     *) *)# *)) *)r3   c                h  "   V P                   P                  4       ;_uu_ 4       pV P                  P                  V4      p\	        V.V P
                  4      pVP                  V P                   4       RRR4       Rp\        XRR7      G Rj  xL
  FT  w  rgV'       d   K  RpV P                  P                  RVVR7        V P                   P                  VV4      G Rj  xL
  KV  	  RV/#   + '       g   i     L; i Ls L!  \         d     T P                  P                  R4        K  i ; i5i)	z
Run a test case by name.
NT)consumeErrorsFz Result reporting for {id} failed)failureidz5Additionally, reporting the reporting failure failed.rB   )rW   gatherReportingResultsrV   
loadByNamer"   rX   rO   r   loggerra   addErrorFallibleBaseException)rN   r]   resultsrH   suiteallSucceededrB   rI   s   &&      r0   rO   WorkerProtocol.runY   s    
 \\0022g<<**84Dvt'C'CDEIIdll# 3
 %1'%NNNOG !L KK2	   ll33  '  O@ <((M 32  O&
 !  ##K	s_   #D2AC.3D2D3D2D!D"D&D2.C>	9	D2D&D/+D2.D//D2c                6    \         P                  ! V4       RR/# )zJ
Set up the worker, moving into given directory for tests to run in
them.
rB   T)oschdir)rN   	directorys   &&r0   startWorkerProtocol.start   s     	4  r3   )rX   rV   rW   N)F)r6   r7   r8   r9   r:   r   re   rZ   r   Run	responderrO   Startrp   r<   r=   r>   s   @r0   rS   rS   M   sY      XF>
 !!*) "*)X ##! $!r3   rS   c                   X  a a ] tR t^t oRtRV 3R llt]P                  R 4       t]	P                  R 4       t
]P                  P                  R 4       tV3R lR lt]P                  P                  V3R lR	 l4       t]P"                  P                  V3R
 lR l4       t]P&                  P                  R 4       t]P*                  P                  V3R lR l4       t]P.                  P                  R 4       t]P2                  P                  R 4       tV3R lR ltR tRtVtV ;t# )LocalWorkerAMPz/
Local implementation of the manager commands.
c                D   < \         SV `  W4       \        4       V n        R # rU   )superrZ   r%   _streams)rN   boxReceiverlocator	__class__s   &&&r0   rZ   LocalWorkerAMP.__init__   s    .&(r3   c                :    R V P                   P                  4       /# )streamId)ry   openrN   s   &r0   
streamOpenLocalWorkerAMP.streamOpen   s    DMM..011r3   c                <    V P                   P                  W4       / # rU   )ry   write)rN   r   datas   &&&r0   streamWriteLocalWorkerAMP.streamWrite   s    H+	r3   c                T    V P                   P                  V P                  4       RR/# )z 
Add a success to the reporter.
rB   T)rW   
addSuccess	_testCase)rN   testNames   &&r0   r   LocalWorkerAMP.addSuccess   s%    
 	/4  r3   c                B   < V ^8  d   QhRS[ RS[RS[S[,          RS[/# )r+   error
errorClassframesrJ   )r)   r-   r   r   )r.   r/   s   "r0   r1   LocalWorkerAMP.__annotate__   s7        S		
 
r3   c           
         \        V4      p\        W4      p\        ^ \        V4      ^4       FL  pVP                  P                  W6,          W6^,           ,          \        W6^,           ,          4      . . 34       KN  	  V# )a`  
Helper to build a C{Failure} with some traceback.

@param error: An C{Exception} instance.

@param errorClass: The class name of the C{error} class.

@param frames: A flat list of strings representing the information need
    to approximatively rebuild C{Failure} frames.

@return: A L{Failure} instance with enough information about a test
   error.
)r   r   rangelenr   appendint)rN   r   r   r   	errorTypera   is   &&&&   r0   _buildFailureLocalWorkerAMP._buildFailure   si    &  
+	%+q#f+q)ANN!!Fq5M3v!e}+=r2F * r3   c                N   < V ^8  d   QhRS[ RS[ RS[RS[RS[S[ S[3,          /# )r+   r   r   errorStreamIdframesStreamIdrJ   r-   r   r   rC   )r.   r/   s   "r0   r1   r      sE     ! !! ! 	!
 ! 
c4i!r3   c                x   RP                  V P                  P                  V4      4      P                  R4      pV P                  P                  V4       Uu. uF  qfP                  R4      NK  	  ppV P	                  \        V4      W'4      pV P                  P                  V P                  V4       RR/# u upi )ao  
Add an error to the reporter.

@param errorStreamId: The identifier of a stream over which the text
    of this error was previously completely sent to the peer.

@param framesStreamId: The identifier of a stream over which the lines
    of the traceback for this error were previously completely sent to
    the peer.

@param error: A message describing the error.
r3   utf-8rB   T)	joinry   finishdecoder   r)   rW   addErrorr   )	rN   r   r   r   r   r   framer   ra   s	   &&&&&    r0   r   LocalWorkerAMP.addError   s    ( --m<=DDWM/3}}/C/CN/S
/SeLL!/S 	 
 $$_U%;ZPdnng64  
   B7c                N   < V ^8  d   QhRS[ RS[RS[ RS[RS[S[ S[3,          /# )r+   r   failStreamId	failClassr   rJ   r   )r.   r/   s   "r0   r1   r      sE     ! !! ! 	!
 ! 
c4i!r3   c                x   RP                  V P                  P                  V4      4      P                  R4      pV P                  P                  V4       Uu. uF  qfP                  R4      NK  	  ppV P	                  \        V4      W74      pV P                  P                  V P                  V4       RR/# u upi )aB  
Add a failure to the reporter.

@param failStreamId: The identifier of a stream over which the text of
    this failure was previously completely sent to the peer.

@param framesStreamId: The identifier of a stream over which the lines
    of the traceback for this error were previously completely sent to the
    peer.
r3   r   rB   T)	r   ry   r   r   r   r)   rW   
addFailurer   )	rN   r   r   r   r   failr   r   ra   s	   &&&&&    r0   r   LocalWorkerAMP.addFailure   s    $ xx,,\:;BB7K/3}}/C/CN/S
/SeLL!/S 	 
 $$_T%:IN84  
r   c                V    V P                   P                  V P                  V4       RR/# )z
Add a skip to the reporter.
rB   T)rW   addSkipr   )rN   r   reasons   &&&r0   r   LocalWorkerAMP.addSkip   s'    
 	T^^V44  r3   c          
      X   < V ^8  d   QhRS[ RS[RS[S[ ,          RS[S[ S[3,          /# )r+   r   r   todorJ   )r-   r   r   r   rC   )r.   r/   s   "r0   r1   r   	  s9     ! !!,/!7?}!	c4i!r3   c                    RP                  V P                  P                  V4      4      P                  R4      p\	        Vf   RMT4      pV P
                  P                  V P                  WE4       RR/# )z
Add an expected failure to the reporter.

@param errorStreamId: The identifier of a stream over which the text
    of this error was previously completely sent to the peer.
r3   r   z	<unknown>rB   T)r   ry   r   r   r#   rW   addExpectedFailurer   )rN   r   r   r   r   _todos   &&&&  r0   r   !LocalWorkerAMP.addExpectedFailure  s_     --m<=DDWMDL[d;''E4  r3   c                V    V P                   P                  V P                  V4       RR/# )z,
Add an unexpected success to the reporter.
rB   T)rW   addUnexpectedSuccessr   )rN   r   r   s   &&&r0   r   #LocalWorkerAMP.addUnexpectedSuccess  s'    
 	))$..$?4  r3   c                    V P                   P                  VR,           4       V P                   P                  4        RR/# )z$
Print test output from the worker.

rB   T)_testStreamr   flush)rN   outs   &&r0   	testWriteLocalWorkerAMP.testWrite  s9    
 	sTz* 4  r3   c                ,   < V ^8  d   QhRS[ RS[RS[/# )r+   r]   rI   rJ   rK   )r.   r/   s   "r0   r1   r   (  s"     , ,( ,J ,9 ,r3   c                F  "   Wn         W n        V P                  P                  V4       VP                  4       p V P	                  \
        P                  VR7      G Rj  xL
 V P                  P                  V4       #  L  T P                  P                  T4       i ; i5i)z
Run a test.
)r]   N)r   rW   	startTestrb   
callRemoter   rr   stopTest)rN   r]   rI   
testCaseIds   &&& r0   rO   LocalWorkerAMP.run(  sw      "x([[]
	,););jQQLL!!(+ RLL!!(+s.   8B!$B A? B #B!?B BB!c                    Wn         R# )z/
Set the stream used to log output from tests.
N)r   )rN   streams   &&r0   setTestStreamLocalWorkerAMP.setTestStream5  s
     "r3   )rW   ry   r   r   )NN) r6   r7   r8   r9   r:   rZ   r$   rs   r   r&   r   r   
AddSuccessr   r   AddErrorr   
AddFailurer   AddSkipr   AddExpectedFailurer   AddUnexpectedSuccessr   	TestWriter   rO   r   r<   r=   __classcell__)r|   r/   s   @@r0   rv   rv      sA    ) 2 2   ))! *! 6 ''! (!> ))! *!4 &&! '! ''11! 2! ))33! 4! ((! )!, ," "r3   rv   c                       ] tR tRtRtRtR# )LocalWorkerAddressi<  zs
A L{IAddress} implementation meant to provide stub addresses for
L{ITransport.getPeer} and L{ITransport.getHost}.
r4   Nr6   r7   r8   r9   r:   r<   r4   r3   r0   r   r   <  s    r3   r   c                   H   a  ] tR tRt o RtR tR tR tR tR t	R t
R	tV tR
# )LocalWorkerTransportiD  z]
A stub transport implementation used to support L{AMP} over a
L{ProcessProtocol} transport.
c                    Wn         R # rU   
_transport)rN   	transports   &&r0   rZ   LocalWorkerTransport.__init__K  s    #r3   c                F    V P                   P                  \        V4       R# )z
Forward data to transport.
Nr   writeToChildr   rN   r   s   &&r0   r   LocalWorkerTransport.writeN  s     	$$%6=r3   c                X    V F#  pV P                   P                  \        V4       K%  	  R# )z@
Emulate C{writeSequence} by iterating data in the C{sequence}.
Nr   )rN   sequencer   s   && r0   writeSequence"LocalWorkerTransport.writeSequenceT  s#     DOO(():DA r3   c                :    V P                   P                  4        R# )z
Closes the transport.
N)r   loseConnectionr   s   &r0   r   #LocalWorkerTransport.loseConnection[  s     	&&(r3   c                    \        4       # z*
Return a L{LocalWorkerAddress} instance.
r   r   s   &r0   getHostLocalWorkerTransport.getHosta       "##r3   c                    \        4       # r   r   r   s   &r0   getPeerLocalWorkerTransport.getPeerg  r   r3   r   N)r6   r7   r8   r9   r:   rZ   r   r   r   r   r   r<   r=   r>   s   @r0   r   r   D  s.     
$>B)$$ $r3   r   c                       ] tR tRtRtRtR# )
NotRunningin  zF
An operation was attempted on a worker process which is not running.
r4   Nr   r4   r3   r0   r   r   n  s    r3   r   c                   x   a  ] tR tRt o RtV 3R lR ltV 3R lR ltR tR tV 3R	 lR
 lt	R t
R tR tRtV tR# )LocalWorkerit  a0  
Local process worker protocol. This worker runs as a local process and
communicates via stdin/out.

@ivar _ampProtocol: The L{AMP} protocol instance used to communicate with
    the worker.

@ivar _logDirectory: The directory where logs will reside.

@ivar _logFile: The main log file for tests output.
c                <   < V ^8  d   QhRS[ RS[S[,          RS[/# )r+   ampProtocollogDirectorylogFile)rv   r   r   r   )r.   r/   s   "r0   r1   LocalWorker.__annotate__  s-     	6 	6#	6 sm	6 		6r3   c                H    Wn         W n        W0n        \        4       V n        R # rU   )_ampProtocol_logDirectory_logFiler   endDeferred)rN   r   r   r   s   &&&&r0   rZ   LocalWorker.__init__  s     ()+3:r3   c                   < V ^8  d   QhRR/# )r+   rJ   Nr4   )r.   r/   s   "r0   r1   r     s      D r3   c                   "   V P                   f   \        4       hV P                  pV P                   P                  \        4        VG Rj  xL
  R#  L  \
         d     R# i ; i5i)z#
Cause the worker process to exit.
N)r   r   r  closeChildFDr   r   )rN   r  s   & r0   exitLocalWorker.exit  sV      >>!,&&##$56	 		s<   AA'A AA A'A A$ A'#A$$A'c                B   V P                   P                  \        V P                  4      4       V P                  P                  RR7       V P                  P                  R4      P                  R4      V n        V P                  P                  R4      P                  R4      V n	        V P                   P                  V P                  4       V P                   P                  \        P                  V P                  P                  R7      pVP!                  R 4       R# )	z<
When connection is made, create the AMP protocol instance.
T)ignoreExistingDirectoryzout.logwzerr.log)ro   c                     R # rU   r4   )xs   &r0   <lambda>,LocalWorker.connectionMade.<locals>.<lambda>  s    tr3   N)r   makeConnectionr   r   r  makedirschildr   _outLog_errLogr   r  r   r   rt   path
addErrback)rN   ds   & r0   connectionMadeLocalWorker.connectionMade  s     	(()=dnn)MN##D#A))//	:??D))//	:??D''6((  ((-- ) 
 	
^$r3   c                |    V P                   P                  4        V P                  P                  4        RV n        R# )zS
On connection lost, close the log files that we're managing for stdin
and stdout.
N)r  closer  r   rN   r   s   &&r0   connectionLostLocalWorker.connectionLost  s+    
 	r3   c                $   < V ^8  d   QhRS[ RR/# )r+   r   rJ   Nr   )r.   r/   s   "r0   r1   r     s     * *7 *t *r3   c                    V P                  V4       V P                  P                  V4       V P                  P                  V4       R# )zz
When the process closes, call C{connectionLost} for cleanup purposes
and forward the information to the C{_ampProtocol}.
N)r  r   r  callbackr  s   &&r0   processEndedLocalWorker.processEnded  s:    
 	F#((0!!&)r3   c                <    V P                   P                  V4       R# )z(
Send data received from stdout to log.
N)r  r   r   s   &&r0   outReceivedLocalWorker.outReceived  s    
 	4 r3   c                <    V P                   P                  V4       R# )z
Write error data to log.
N)r  r   r   s   &&r0   errReceivedLocalWorker.errReceived  s     	4 r3   c                    V\         8X  d   V P                  P                  V4       R# \        P                  ! WV4       R# )zD
Handle data received on the specific pipe for the C{_ampProtocol}.
N)r   r   dataReceivedr   childDataReceived)rN   childFDr   s   &&&r0   r-  LocalWorker.childDataReceived  s1     ((**40--dTBr3   )r   r  r  r  r  r  r   N)r6   r7   r8   r9   r:   rZ   r  r  r  r#  r&  r)  r-  r<   r=   r>   s   @r0   r   r   t  sH     
	6 	6 %"* *!!C Cr3   r   )Er:   rm   typingr   r   r   r   r   r   r   r	   unittestr
   zope.interfacer   attrsr   r   r   twisted.internet.deferr   r   twisted.internet.errorr   twisted.internet.interfacesr   r   twisted.internet.protocolr   twisted.loggerr   twisted.protocols.ampr   twisted.python.failurer   twisted.python.filepathr   twisted.python.reflectr   twisted.trial._distr   r   r   r   "twisted.trial._dist.workerreporterr   twisted.trial.reporterr    twisted.trial.runnerr!   r"   twisted.trial.unittestr#   r   r$   r%   r&   	Exceptionr)   r@   rF   rQ   WorkerActionrS   rv   r   r   r   r   r4   r3   r0   <module>rD     s,   
 R R R  &  & 9 . < 5 ! % * , .  > - 7 ' ; ; i  	 X  T])B-/0@!S @!Fi"S i"X X   Z&$ &$ &$R ]C/ ]Cr3   