Commit e06c26c5 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

packer/rpc: Implement Builder.Cancel

parent 1b557d77
......@@ -93,7 +93,9 @@ func (b *builder) Run(ui packer.Ui, hook packer.Hook) packer.Artifact {
}
func (b *builder) Cancel() {
if err := b.client.Call("Builder.Cancel", new(interface{}), new(interface{})); err != nil {
panic(err)
}
}
func (b *BuilderServer) Prepare(args *BuilderPrepareArgs, reply *error) error {
......@@ -135,3 +137,8 @@ func (b *BuilderServer) Run(args *BuilderRunArgs, reply *interface{}) error {
return nil
}
func (b *BuilderServer) Cancel(args *interface{}, reply*interface{}) error {
b.builder.Cancel()
return nil
}
......@@ -73,6 +73,10 @@ func TestBuilderRPC(t *testing.T) {
assert.Equal(artifact.Id(), testBuilderArtifact.Id(), "should have artifact Id")
}
// Test Cancel
bClient.Cancel()
assert.True(b.cancelCalled, "cancel should be called")
}
func TestBuilder_ImplementsBuilder(t *testing.T) {
......
......@@ -66,7 +66,7 @@ func serveSingleConn(s *rpc.Server) string {
defer l.Close()
conn, err := l.Accept()
if err != nil {
return
panic(err)
}
s.ServeConn(conn)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment