Esempio n. 1
0
func TestPipeline(t *testing.T) {
	var p goconc.Pipeline
	mulStage := p.Stage(10)
	addStage := p.Stage(1)
	const N = 100
	x := 0
	for i := 0; i < N; i++ {
		i := i
		mulStage.In <- func() {
			ii := i * i
			addStage.In <- func() {
				x += ii
			}
		}
	}
	p.Wait()

	x0 := 0
	for i := 0; i < N; i++ {
		x0 += i * i
	}
	if x0 != x {
		t.Fatalf("expected/got: %d/%d", x0, x)
	}
}
Esempio n. 2
0
func main() {
	os.Mkdir(cacheRoot, 0755)
	log.SetFlags(log.Ltime | log.Lmicroseconds)
	nRuns := flag.Int("num-runs", 1, "Number of runs")
	flag.Parse()

	var p goconc.Pipeline
	builderStage := p.Stage(5)
	discoverStage := p.Stage(5)
	processStage := p.Stage(20)
	mergeStage := p.Stage(1)

	suppressions := make(map[string]int)
	for _, w := range waterfallList {
		w := w
		builderStage.In <- func() {
			log.Printf("builderStage: %s", w)
			for _, b := range getBuilderList(w) {
				path := fmt.Sprintf("%s/builders/%s/builds", w, b)
				discoverStage.In <- func() {
					log.Printf("discoverStage: %s", path)
					for _, l := range getRunLogs(path, *nRuns) {
						logUrl, err := url.Parse(l)
						if err != nil {
							continue
						}
						processStage.In <- func() {
							log.Printf("processStage: %s", logUrl)
							supp := processLog(logUrl)
							if supp == nil {
								return
							}
							mergeStage.In <- func() {
								for s, n := range supp {
									suppressions[s] += n
								}
							}
						}
					}
				}
			}
		}
	}
	p.Wait()
	output(suppressions)
}