コード例 #1
0
func (a *Agent) start() {
	if a.cmd != nil {
		log.Fatal("Cannot call start(): program already running!")
	}
	if a.killcount > 0 {
		return
	}
	cmd := exec.Command(a.args[0], a.args[1:]...)
	stdout, err := cmd.StdoutPipe()
	if err != nil {
		log.Fatal("Unable to open pipe to stdout: %v", err)
	}
	stderr, err := cmd.StderrPipe()
	if err != nil {
		log.Fatal("Unable to open pipe to stderr: %v", err)
	}
	if state.Local() {
		cmd.Dir = a.dir
	}
	go copyLines(a.Name, stdout)
	go copyLines(a.Name, stderr)
	log.Printf("Starting %v", a)
	err = cmd.Start()
	if err != nil {
		log.Fatalf("Could't spawn %v: %s", a, err)
	}
	go func() {
		err := cmd.Wait()
		a.Lock()
		defer a.Unlock()

		// Not the active command
		if a.cmd != cmd {
			return
		}

		var d string
		if err != nil {
			d = fmt.Sprintf("Command exited unexpectedly: %s (%s)", cmd, err)
		} else {
			d = fmt.Sprintf("Command exited unexpectedly (but cleanly!): %s", cmd)
		}
		state.RecordDisqualifier(d)

		state.WaitGroup().Exit()
	}()

	a.cmd = cmd
}
コード例 #2
0
func (h *Harness) losef(msg string, v ...interface{}) {
	disqualifier := fmt.Sprintf(msg, v...)
	state.RecordDisqualifier(disqualifier)
	state.WaitGroup().Exit()
}