Skip to content

Commit 4d53934

Browse files
authored
fix: (Re-)enable TestPasswordTerminalState test (#3169)
1 parent 5312296 commit 4d53934

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

cli/cliui/prompt_test.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,6 @@ func newPrompt(ptty *ptytest.PTY, opts cliui.PromptOptions, cmdOpt func(cmd *cob
165165
}
166166

167167
func TestPasswordTerminalState(t *testing.T) {
168-
// TODO: fix this test so that it runs reliably
169-
t.Skip()
170-
171168
if os.Getenv("TEST_SUBPROCESS") == "1" {
172169
passwordHelper()
173170
return
@@ -192,20 +189,21 @@ func TestPasswordTerminalState(t *testing.T) {
192189
defer process.Kill()
193190

194191
ptty.ExpectMatch("Password: ")
195-
time.Sleep(100 * time.Millisecond) // wait for child process to turn off echo and start reading input
196192

197-
echo, err := ptyWithFlags.EchoEnabled()
198-
require.NoError(t, err)
199-
require.False(t, echo, "echo is on while reading password")
193+
require.Eventually(t, func() bool {
194+
echo, err := ptyWithFlags.EchoEnabled()
195+
return err == nil && !echo
196+
}, 5*time.Second, 50*time.Millisecond, "echo is on while reading password")
200197

201198
err = process.Signal(os.Interrupt)
202199
require.NoError(t, err)
203200
_, err = process.Wait()
204201
require.NoError(t, err)
205202

206-
echo, err = ptyWithFlags.EchoEnabled()
207-
require.NoError(t, err)
208-
require.True(t, echo, "echo is off after reading password")
203+
require.Eventually(t, func() bool {
204+
echo, err := ptyWithFlags.EchoEnabled()
205+
return err == nil && echo
206+
}, 5*time.Second, 50*time.Millisecond, "echo is off after reading password")
209207
}
210208

211209
// nolint:unused

0 commit comments

Comments
 (0)