vmcli/test: run shell after providing input
In some cases, `Run()` can read from input before we have written anything to it.
This commit is contained in:
parent
d828096cbf
commit
76a6ddc3a4
1 changed files with 4 additions and 4 deletions
|
@ -75,16 +75,16 @@ func newTestVMCLIWithLogo(t *testing.T, printLogo bool) *executor {
|
||||||
Stdin: e.in,
|
Stdin: e.in,
|
||||||
Stdout: e.out,
|
Stdout: e.out,
|
||||||
})
|
})
|
||||||
go func() {
|
|
||||||
require.NoError(t, e.cli.Run())
|
|
||||||
close(e.ch)
|
|
||||||
}()
|
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *executor) runProg(t *testing.T, commands ...string) {
|
func (e *executor) runProg(t *testing.T, commands ...string) {
|
||||||
cmd := strings.Join(commands, "\n") + "\n"
|
cmd := strings.Join(commands, "\n") + "\n"
|
||||||
e.in.WriteString(cmd + "\n")
|
e.in.WriteString(cmd + "\n")
|
||||||
|
go func() {
|
||||||
|
require.NoError(t, e.cli.Run())
|
||||||
|
close(e.ch)
|
||||||
|
}()
|
||||||
select {
|
select {
|
||||||
case <-e.ch:
|
case <-e.ch:
|
||||||
case <-time.After(time.Second):
|
case <-time.After(time.Second):
|
||||||
|
|
Loading…
Reference in a new issue