// executeTestCases loops over the test cases to execute them and upload their outputs.
executeTestCases loops over the test cases to execute them and upload their outputs.
// executeTestCases loops over the test cases to execute them and upload their outputs .
func (e *Executor) executeTestCases() error {
	runFunc, err := e.getRunFunction()
	if err != nil {
		return err
	}
	jobs := make(chan string, e.numTestCases)
	done := make(chan error, 1)
	go func() {
		for i := 0; i < e.numTestCases; i++ {
			testCaseOutput, more := <-jobs
			if !more {
				done <- nil
				return
			}
			if err := e.FileService.UploadFile(testCaseOutput, e.UploadAuthorizedServerURL); err != nil {
				done <- fmt.Errorf("error uploading test case output: %w", err)
				return
			}
		}
		done <- nil
	}()
	for _, testCase := range e.testCases {
		if err := runFunc(testCase); err != nil {
			close(jobs)
			if jobErr := <-done; err != nil {
				return multierror.Append(err, jobErr)
			}
			return err
		}
		jobs <- testCase.output
	}
	return <-done
}
func ( e * Executor ) executeTestCases ( ) error { runFunc , err := e . getRunFunction ( ) if err != nil { return err } jobs := make ( chan string , e . numTestCases ) done := make ( chan error , 1 ) go func ( ) { for i := 0 ; i < e . numTestCases ; i ++ { testCaseOutput , more := <- jobs if ! more { done <- nil return } if err := e . FileService . UploadFile ( testCaseOutput , e . UploadAuthorizedServerURL ) ; err != nil { done <- fmt . Errorf ( " " , err ) return } } done <- nil } ( ) for _ , testCase := range e . testCases { if err := runFunc ( testCase ) ; err != nil { close ( jobs ) if jobErr := <- done ; err != nil { return multierror . Append ( err , jobErr ) } return err } jobs <- testCase . output } return <- done }
executeTestCases loops over the test cases to execute them and upload their outputs.
executeTestCases loops over the test cases to execute them and upload their outputs .
// upload outputs in a worker