Skip to content

Commit

Permalink
Sending signal with a Batch seemed to work at first try.
Browse files Browse the repository at this point in the history
  • Loading branch information
skalle committed Aug 12, 2020
1 parent 4e4707b commit 9e7e7e0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions expect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,26 @@ func ExampleGExpect_SendSignal() {
// Output: Got the USR1 Signal
}

// ExampleGExpect_SendSignal_Batch is an example of using SendSignal in a batch.
func ExampleGExpect_SendSignal_Batch() {
exp, r, err := Spawn("testdata/traptest.sh", 30*time.Second)
if err != nil {
fmt.Printf("Spawn failed: %v\n", err)
return
}
if _, err := exp.ExpectBatch([]Batcher{
&BExp{`Waiting for signal`},
&BSig{syscall.SIGUSR1},
&BExp{`USR1`},
}, time.Second*20); err != nil {
fmt.Printf("ExpectBatch failed: %v\n", err)
return
}
fmt.Println("Signal received")
<-r
// Output: Signal received
}

var tMap map[string][]Batcher

// buildTest Reads the sends and expected outputs from the testfiles eg.
Expand Down

0 comments on commit 9e7e7e0

Please sign in to comment.