diff --git a/command/build_test.go b/command/build_test.go index 7cdf4a9a4..e334f0055 100644 --- a/command/build_test.go +++ b/command/build_test.go @@ -76,6 +76,7 @@ func TestBuildOnlyFileMultipleFlags(t *testing.T) { args := []string{ "-only=chocolate", "-only=cherry", + "-only=apple", filepath.Join(testFixture("build-only"), "template.json"), } @@ -94,6 +95,9 @@ func TestBuildOnlyFileMultipleFlags(t *testing.T) { if !fileExists("cherry.txt") { t.Error("Expected to find cherry.txt") } + if !fileExists("apple.txt") { + t.Error("Expected to find apple.txt") + } } func TestBuildExceptFileCommaFlags(t *testing.T) { diff --git a/packer/core.go b/packer/core.go index c81745148..5c68b348b 100644 --- a/packer/core.go +++ b/packer/core.go @@ -182,6 +182,7 @@ func (c *Core) Build(n string) (Build, error) { for _, rawP := range rawPs { // If we skip, ignore rawP.OnlyExcept.Except = append(rawP.OnlyExcept.Except, c.except...) + rawP.OnlyExcept.Only = append(rawP.OnlyExcept.Only, c.only...) if rawP.OnlyExcept.Skip(rawName) { continue }