Commit aa143a33 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

packer: TargettedUi properly targets machine-readable data

parent 89be12ae
...@@ -140,8 +140,8 @@ func (u *TargettedUi) Error(message string) { ...@@ -140,8 +140,8 @@ func (u *TargettedUi) Error(message string) {
} }
func (u *TargettedUi) Machine(t string, args ...string) { func (u *TargettedUi) Machine(t string, args ...string) {
// Just pass it through for now. // Prefix in the target, then pass through
u.Ui.Machine(t, args...) u.Ui.Machine(fmt.Sprintf("%s,%s", u.Target, t), args...)
} }
func (u *TargettedUi) prefixLines(arrow bool, message string) string { func (u *TargettedUi) prefixLines(arrow bool, message string) string {
......
...@@ -41,21 +41,21 @@ func TestTargettedUi(t *testing.T) { ...@@ -41,21 +41,21 @@ func TestTargettedUi(t *testing.T) {
assert := asserts.NewTestingAsserts(t, true) assert := asserts.NewTestingAsserts(t, true)
bufferUi := testUi() bufferUi := testUi()
TargettedUi := &TargettedUi{ targettedUi := &TargettedUi{
Target: "foo", Target: "foo",
Ui: bufferUi, Ui: bufferUi,
} }
TargettedUi.Say("foo") targettedUi.Say("foo")
assert.Equal(readWriter(bufferUi), "==> foo: foo\n", "should have prefix") assert.Equal(readWriter(bufferUi), "==> foo: foo\n", "should have prefix")
TargettedUi.Message("foo") targettedUi.Message("foo")
assert.Equal(readWriter(bufferUi), " foo: foo\n", "should have prefix") assert.Equal(readWriter(bufferUi), " foo: foo\n", "should have prefix")
TargettedUi.Error("bar") targettedUi.Error("bar")
assert.Equal(readWriter(bufferUi), "==> foo: bar\n", "should have prefix") assert.Equal(readWriter(bufferUi), "==> foo: bar\n", "should have prefix")
TargettedUi.Say("foo\nbar") targettedUi.Say("foo\nbar")
assert.Equal(readWriter(bufferUi), "==> foo: foo\n==> foo: bar\n", "should multiline") assert.Equal(readWriter(bufferUi), "==> foo: foo\n==> foo: bar\n", "should multiline")
} }
......
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