@@ -165,9 +165,6 @@ func newPrompt(ptty *ptytest.PTY, opts cliui.PromptOptions, cmdOpt func(cmd *cob
165
165
}
166
166
167
167
func TestPasswordTerminalState (t * testing.T ) {
168
- // TODO: fix this test so that it runs reliably
169
- t .Skip ()
170
-
171
168
if os .Getenv ("TEST_SUBPROCESS" ) == "1" {
172
169
passwordHelper ()
173
170
return
@@ -192,20 +189,21 @@ func TestPasswordTerminalState(t *testing.T) {
192
189
defer process .Kill ()
193
190
194
191
ptty .ExpectMatch ("Password: " )
195
- time .Sleep (100 * time .Millisecond ) // wait for child process to turn off echo and start reading input
196
192
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" )
200
197
201
198
err = process .Signal (os .Interrupt )
202
199
require .NoError (t , err )
203
200
_ , err = process .Wait ()
204
201
require .NoError (t , err )
205
202
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" )
209
207
}
210
208
211
209
// nolint:unused
0 commit comments