diff --git a/packer/build.go b/packer/build.go index 7a1723da4..d2502625a 100644 --- a/packer/build.go +++ b/packer/build.go @@ -91,4 +91,5 @@ func (b *coreBuild) Run(ui Ui) Artifact { // Cancels the build if it is running. func (b *coreBuild) Cancel() { + b.builder.Cancel() } diff --git a/packer/build_test.go b/packer/build_test.go index aed5b8ecb..a8870a59a 100644 --- a/packer/build_test.go +++ b/packer/build_test.go @@ -92,3 +92,15 @@ func TestBuild_RunBeforePrepare(t *testing.T) { testBuild().Run(testUi()) } + +func TestBuild_Cancel(t *testing.T) { + assert := asserts.NewTestingAsserts(t, true) + + build := testBuild() + build.Cancel() + + coreB := build.(*coreBuild) + + builder := coreB.builder.(*TestBuilder) + assert.True(builder.cancelCalled, "cancel should be called") +}