From 94cfe39a766339322ff435d356673c5191b13c4f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 3 Jun 2013 16:06:04 -0700 Subject: [PATCH] packer: coreBuild.Cancel calls the builder Cancel method --- packer/build.go | 1 + packer/build_test.go | 12 ++++++++++++ 2 files changed, 13 insertions(+) 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") +}