/usr/share/gocode/src/github.com/smartystreets/goconvey/web/server/executor/coordinator.go is in golang-github-smartystreets-goconvey-dev 1.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | package executor
import (
"fmt"
"log"
"sync"
"github.com/smartystreets/goconvey/web/server/contract"
)
type concurrentCoordinator struct {
batchSize int
queue chan *contract.Package
folders []*contract.Package
shell contract.Shell
waiter sync.WaitGroup
}
func (self *concurrentCoordinator) ExecuteConcurrently() {
self.enlistWorkers()
self.scheduleTasks()
self.awaitCompletion()
self.checkForErrors()
}
func (self *concurrentCoordinator) enlistWorkers() {
for i := 0; i < self.batchSize; i++ {
self.waiter.Add(1)
go self.worker(i)
}
}
func (self *concurrentCoordinator) worker(id int) {
for folder := range self.queue {
if !folder.Active {
log.Printf("Skipping concurrent execution: %s\n", folder.Name)
continue
}
log.Printf("Executing concurrent tests: %s\n", folder.Name)
folder.Output, folder.Error = self.shell.GoTest(folder.Path)
}
self.waiter.Done()
}
func (self *concurrentCoordinator) scheduleTasks() {
for _, folder := range self.folders {
self.queue <- folder
}
}
func (self *concurrentCoordinator) awaitCompletion() {
close(self.queue)
self.waiter.Wait()
}
func (self *concurrentCoordinator) checkForErrors() {
for _, folder := range self.folders {
if folder.Error != nil && folder.Output == "" {
fmt.Println(folder.Path, folder.Error)
panic(folder.Error)
}
}
}
func newCuncurrentCoordinator(folders []*contract.Package, batchSize int, shell contract.Shell) *concurrentCoordinator {
self := &concurrentCoordinator{}
self.queue = make(chan *contract.Package)
self.folders = folders
self.batchSize = batchSize
self.shell = shell
return self
}
|