Example #1
0
func (S) TestKillAbortedExecTask(c *C) {
	p := pipe.Script(
		pipe.TaskFunc(func(*pipe.State) error { return fmt.Errorf("boom") }),
		pipe.Exec("will-not-run"),
	)
	_, err := pipe.Output(p)
	c.Assert(err, ErrorMatches, "boom")
}
Example #2
0
func (S) TestErrorHandling(c *C) {
	sync := make(chan bool)
	p := pipe.Script(
		pipe.Line(
			pipe.TaskFunc(func(*pipe.State) error {
				sync <- true
				return fmt.Errorf("err1")
			}),
			pipe.TaskFunc(func(*pipe.State) error {
				<-sync
				return fmt.Errorf("err2")
			}),
		),
		pipe.Print("never happened"),
	)
	output, err := pipe.Output(p)
	if err.Error() != "err1; err2" && err.Error() != "err2; err1" {
		c.Fatalf(`want "err1; err2" or "err2; err1"; got %q`, err.Error())
	}
	c.Assert(string(output), Equals, "")
}