
    "e %                         d dl Z d dlmZ d dlZd dlmZ d dlZd dlZd dl	Z	d dl
Z
d Zd Z G d de	j                        Z G d d	e	j                        Zy)
    N)thread)pydev_runfiles_xml_rpcc                     t        | t        j                        r| j                  D ]  }t	        ||        y t        | t        j
                        r|j                  |        y y )N)
isinstanceunittest	TestSuite_testsflatten_test_suiteTestCaseappend)
test_suiteretts      I/usr/lib/python3/dist-packages/_pydev_runfiles/pydev_runfiles_parallel.pyr
   r
      sT    *h001"" 	'Aq#&	' 
J 1 1	2

: 
3    c                    	 ddl m}  |       y	 g }g }|dk(  ri }	| D ]P  }
g }t        |
|       |D ];  }
|
j                  |
j                  f}|	j                  |g       j                  |
       = R |	j                         D ]  \  }} |j                  |         t        |      |k  rgt        |      }n[|dk(  rH| D ])  }
g }t        |
|       |D ]  }
|j                  |
g        + t        |      |k  rt        |      }nt        d|      |D ]d  }g }|D ]J  }	 |j                  j                  dz   |j                  z   }|j                  |j                  dz   |z          L |j                  |       f |d	k  ryt        j                   j#                  d
|d       t%        j$                         }|D ]  }|j'                  |d        g }g }t)        |      D ]  }t+        |      }|j                  |       |j-                          |j.                  }|r.|j                  t1        ||||j3                  d      |             k|j                  t1        |||              |D ]  }|j-                           d}|r1d}|D ]'  }|j4                  rd}t7        j8                  d        n |r1|D ]  }|j;                           y#  Y xY w# t        $ r* |j                  j                  dz   |j                  z   }Y w xY w)aC  
    @param tests: list(PydevTestSuite)
        A list with the suites to be run

    @param split: str
        Either 'module' or the number of tests that should be run in each batch

    @param coverage_files: list(file)
        A list with the files that should be used for giving coverage information (if empty, coverage information
        should not be gathered).

    @param coverage_include: str
        The pattern that should be included in the coverage.

    @return: bool
        Returns True if the tests were actually executed in parallel. If the tests were not executed because only 1
        should be used (e.g.: 2 jobs were requested for running 1 test), False will be returned and no tests will be
        run.

        It may also return False if in debug mode (in which case, multi-processes are not accepted)
    r   )get_global_debuggerFmoduletestszDo not know how to handle: .|   z Running tests in parallel with: z jobs.
blockTg?)_pydevd_bundle.pydevd_commr   r
   __pydev_pyfile____pydev_module_name__
setdefaultr   itemslenAssertionError	__class____name___testMethodNameAttributeError_TestCase__testMethodNamesysstdoutwriteQueueputrangeCommunicationThreadstartportClientThreadpopfinishedtimesleepshutdown)r   jobssplit	verbositycoverage_filescoverage_includer   tests_queuequeue_elementsmodule_to_teststestlstkey
test_casestest_queue_elements	test_case	test_namequeueitem	providersclientsitest_cases_providerr/   clientclient_aliveproviders                              r   execute_tests_in_parallelrN      sW   ,B , - KN 	ADCtS) A,,d.H.HI**33::4@A	A *//1 	)JC!!%(	) ~%~&D	'	 	.DCtS) .%%tf-.	. ~%~&D GHH$ 0
 # 	UIe%//883>AZAZZ	
  &&y'A'AC'G)'ST	U 	./0 axJJTKLKKME %		$e	$% IG4[ 
=1%8,-!!#"''NN<4N<N<Nq<QScdeNN<4;<
=   L
 	F??#

2	    wV " e%//883>AdAdd	es   K &KK/LLc                   6    e Zd Zd Zd Zd Zd Zd Zd Zd Z	y)	r-   c                    t         j                  j                  |        d| _        || _        d| _        ddlm} ddlm	}  ||j                         dfd      }|j                  | j                         |j                  | j                         |j                  | j                         |j                  | j                         |j                   j#                         d   | _        || _        y )NTFr   )SimpleXMLRPCServer)pydev_localhost)logRequests   )	threadingThread__init__daemonrE   r2   _pydev_bundle.pydev_importsrQ   _pydev_bundlerR   get_localhostregister_functionGetTestsToRunnotifyStartTest
notifyTestnotifyCommandssocketgetsocknamer/   server)selfr;   rQ   rR   rc   s        r   rW   zCommunicationThread.__init__   s    !!$' 
B1 $_%B%B%Da$HV[\  !3!34  !5!56  1  !4!45MM--/2	r   c                 `    	 | j                   j                  d      }|S #  d| _        g cY S xY w)z
        @param job_id:

        @return: list(str)
            Each entry is a string in the format: filename|Test.testName
        Fr   T)rE   getr2   )rd   job_idr   s      r   r]   z!CommunicationThread.GetTestsToRun   s3    	**..u.-CJ	 DMIs     -c                 P    |D ]!  } t        | |d         |g|d   i |d    # y)Nr   rT   r   T)getattr)rd   rg   commandscommands       r   r`   z"CommunicationThread.notifyCommands   s?     	IG%GD'!*%fHwqzHWQZH	I r   c                 .    t        j                  |i | yNT)r   r^   rd   rg   argskwargss       r   r^   z#CommunicationThread.notifyStartTest   s    ..??r   c                 .    t        j                  |i | yrm   )r   r_   rn   s       r   r_   zCommunicationThread.notifyTest   s    ))4:6:r   c                 t    t        | j                  d      r| j                  j                          y d| _        y )Nr5   T)hasattrrc   r5   	_shutdownrd   s    r   r5   zCommunicationThread.shutdown   s'    4;;
+KK  "!DNr   c                     t        | j                  d      r| j                  j                          y d| _        | j                  s(| j                  j	                          | j                  s'y y )Nr5   F)rs   rc   serve_foreverrt   handle_requestru   s    r   runzCommunicationThread.run   sG    4;;
+KK%%'"DNnn**, nnr   N)
r#   
__module____qualname__rW   r]   r`   r^   r_   r5   ry    r   r   r-   r-      s%    ""-r   r-   c                        e Zd ZddZd Zd Zy)r0   Nc                     t         j                  j                  |        d| _        || _        || _        || _        d| _        || _        || _	        y )NTF)
rU   rV   rW   rX   r/   rg   r8   r2   coverage_output_filer:   )rd   rg   r/   r8   r   r:   s         r   rW   zClientThread.__init__   sI    !!$'	"$8! 0r   c                 F    	 |j                  |j                  d             !)NrT   )r)   read)rd   pipetargets      r   _reader_threadzClientThread._reader_thread   s    LL1& r   c                    	 ddl m} t        j                  |j                  t        | j                        t        | j                        t        | j                        g}| j                  rB| j                  r6|j                  | j                         |j                  | j                         dd l}	 |j                  |t        j                  d      }|j-                          	 d| _        y # d| _        w xY w)Nr   )pydev_runfiles_parallel_clientF)envshellT)_pydev_runfilesr   r'   
executable__file__strrg   r/   r8   r   r:   r   
subprocessPopenosenvironPIPEr   start_new_threadr   r(   stderrwaitr2   )rd   r   ro   r   procs        r   ry   zClientThread.run   s    "	!F .77DKK DIIDNN#D ((T-B-BD556D112 "''"**E'J		 !DMDDMs   C#C. .	C7)NN)r#   rz   r{   rW   r   ry   r|   r   r   r0   r0      s    1'#!r   r0   )r   "_pydev_bundle._pydev_saved_modulesr   rE   r*   r   r   r3   r   rU   r'   r
   rN   rV   r-   r0   r|   r   r   <module>r      sN     5  2  	  
uv<-)** <-D3!9## 3!r   