mirror of
https://github.com/hashicorp/packer.git
synced 2026-09-19 06:21:41 -04:00
packer_test: add Tee pipe gadget
When troubleshooting a pipeline for a test, it can be useful to print the input out without necessarily preventing the pipeline to work. The Tee gadget is exactly made for this purpose, the input of the Tee is printed out through `t.Log`, and the input is forwarded to the next step in the pipeline.
This commit is contained in:
committed by
Lucas Bajolet
parent
830ac98e39
commit
d175625869
@@ -5,6 +5,7 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Pipe is any command that allows piping two gadgets together
|
||||
@@ -44,6 +45,16 @@ func LineCount() Pipe {
|
||||
})
|
||||
}
|
||||
|
||||
// Tee pipes the output to stdout (as t.Logf) and forwards it, unaltered
|
||||
//
|
||||
// This is useful typically for troubleshooting a pipe that misbehaves
|
||||
func Tee(t *testing.T) Pipe {
|
||||
return CustomPipe(func(s string) (string, error) {
|
||||
t.Logf(s)
|
||||
return s, nil
|
||||
})
|
||||
}
|
||||
|
||||
// Tester is the end of a pipe for testing purposes.
|
||||
//
|
||||
// Once multiple commands have been piped together in a pipeline, we can
|
||||
|
||||
Reference in New Issue
Block a user