RunDnoteCmd runs a dnote command
(t *testing.T, opts RunDnoteCmdOptions, binaryName string, arg ...string)
| 145 | |
| 146 | // RunDnoteCmd runs a dnote command |
| 147 | func RunDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, binaryName string, arg ...string) string { |
| 148 | t.Logf("running: %s %s", binaryName, strings.Join(arg, " ")) |
| 149 | |
| 150 | cmd, stderr, stdout, err := NewDnoteCmd(opts, binaryName, arg...) |
| 151 | if err != nil { |
| 152 | t.Logf("\n%s", stdout) |
| 153 | t.Fatal(errors.Wrap(err, "getting command").Error()) |
| 154 | } |
| 155 | |
| 156 | cmd.Env = append(cmd.Env, "DNOTE_DEBUG=1") |
| 157 | |
| 158 | if err := cmd.Run(); err != nil { |
| 159 | t.Logf("\n%s", stdout) |
| 160 | t.Fatal(errors.Wrapf(err, "running command %s", stderr.String())) |
| 161 | } |
| 162 | |
| 163 | // Print stdout if and only if test fails later |
| 164 | t.Logf("\n%s", stdout) |
| 165 | |
| 166 | return stdout.String() |
| 167 | } |
| 168 | |
| 169 | // WaitDnoteCmd runs a dnote command and passes stdout to the callback. |
| 170 | func WaitDnoteCmd(t *testing.T, opts RunDnoteCmdOptions, runFunc func(io.Reader, io.WriteCloser) error, binaryName string, arg ...string) (string, error) { |