mirror of
				https://github.com/microsoft/playwright.git
				synced 2025-06-26 21:40:17 +00:00 
			
		
		
		
	chore(test runner): use helper method in JobDispatcher (#27278)
This commit is contained in:
		
							parent
							
								
									7bd8032439
								
							
						
					
					
						commit
						32a50e2d90
					
				| @ -50,36 +50,7 @@ export class Dispatcher { | ||||
|     this._failureTracker = failureTracker; | ||||
|   } | ||||
| 
 | ||||
|   private _processFullySkippedJobs() { | ||||
|     // If all the tests in a group are skipped, we report them immediately
 | ||||
|     // without sending anything to a worker. This avoids creating unnecessary worker processes.
 | ||||
|     //
 | ||||
|     // However, if there is at least one non-skipped test in a group, we'll send
 | ||||
|     // the whole group to the worker process and report tests in the natural order,
 | ||||
|     // with skipped tests mixed in-between non-skipped. This makes
 | ||||
|     // for a better reporter experience.
 | ||||
|     while (!this._isStopped && this._queue.length) { | ||||
|       const group = this._queue[0]; | ||||
|       const allTestsSkipped = group.tests.every(test => test.expectedStatus === 'skipped'); | ||||
|       if (!allTestsSkipped) | ||||
|         break; | ||||
| 
 | ||||
|       for (const test of group.tests) { | ||||
|         const result = test._appendTestResult(); | ||||
|         result.status = 'skipped'; | ||||
|         this._reporter.onTestBegin(test, result); | ||||
|         this._reportTestEnd(test, result); | ||||
|       } | ||||
|       this._queue.shift(); | ||||
|     } | ||||
| 
 | ||||
|     // If all remaining tests were skipped, resolve finished state.
 | ||||
|     this._checkFinished(); | ||||
|   } | ||||
| 
 | ||||
|   private async _scheduleJob() { | ||||
|     this._processFullySkippedJobs(); | ||||
| 
 | ||||
|     // 1. Find a job to run.
 | ||||
|     if (this._isStopped || !this._queue.length) | ||||
|       return; | ||||
| @ -107,6 +78,11 @@ export class Dispatcher { | ||||
|   } | ||||
| 
 | ||||
|   private async _startJobInWorker(index: number, job: TestGroup) { | ||||
|     const stopCallback = () => this.stop().catch(() => {}); | ||||
|     const jobDispatcher = new JobDispatcher(job, this._reporter, this._failureTracker, stopCallback); | ||||
|     if (jobDispatcher.skipWholeJob()) | ||||
|       return; | ||||
| 
 | ||||
|     let worker = this._workerSlots[index].worker; | ||||
| 
 | ||||
|     // 1. Restart the worker if it has the wrong hash or is being stopped already.
 | ||||
| @ -116,9 +92,6 @@ export class Dispatcher { | ||||
|       if (this._isStopped) // Check stopped signal after async hop.
 | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     const stopCallback = () => this.stop().catch(() => {}); | ||||
|     const jobDispatcher = new JobDispatcher(job, this._reporter, this._failureTracker, stopCallback); | ||||
|     this._workerSlots[index].jobDispatcher = jobDispatcher; | ||||
| 
 | ||||
|     // 2. Start the worker if it is down.
 | ||||
| @ -540,6 +513,22 @@ class JobDispatcher { | ||||
|     ]; | ||||
|   } | ||||
| 
 | ||||
|   skipWholeJob(): boolean { | ||||
|     // If all the tests in a group are skipped, we report them immediately
 | ||||
|     // without sending anything to a worker. This avoids creating unnecessary worker processes.
 | ||||
|     //
 | ||||
|     // However, if there is at least one non-skipped test in a group, we'll send
 | ||||
|     // the whole group to the worker process and report tests in the natural order,
 | ||||
|     // with skipped tests mixed in-between non-skipped. This makes
 | ||||
|     // for a better reporter experience.
 | ||||
|     const allTestsSkipped = this._job.tests.every(test => test.expectedStatus === 'skipped'); | ||||
|     if (allTestsSkipped) { | ||||
|       this._massSkipTestsFromRemaining(new Set(this._remainingByTestId.keys()), []); | ||||
|       return true; | ||||
|     } | ||||
|     return false; | ||||
|   } | ||||
| 
 | ||||
|   currentlyRunning() { | ||||
|     return this._currentlyRunning; | ||||
|   } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Dmitry Gozman
						Dmitry Gozman