(ctx context.Context, ptty *ptytest.PTY, opts cliui.PromptOptions, invOpt func(inv *serpent.Invocation))
| 226 | } |
| 227 | |
| 228 | func newPrompt(ctx context.Context, ptty *ptytest.PTY, opts cliui.PromptOptions, invOpt func(inv *serpent.Invocation)) (string, error) { |
| 229 | value := "" |
| 230 | cmd := &serpent.Command{ |
| 231 | Handler: func(inv *serpent.Invocation) error { |
| 232 | var err error |
| 233 | value, err = cliui.Prompt(inv, opts) |
| 234 | return err |
| 235 | }, |
| 236 | } |
| 237 | |
| 238 | inv := cmd.Invoke() |
| 239 | // Optionally modify the cmd |
| 240 | if invOpt != nil { |
| 241 | invOpt(inv) |
| 242 | } |
| 243 | inv.Stdout = ptty.Output() |
| 244 | inv.Stderr = ptty.Output() |
| 245 | inv.Stdin = ptty.Input() |
| 246 | return value, inv.WithContext(ctx).Run() |
| 247 | } |
| 248 | |
| 249 | func TestPasswordTerminalState(t *testing.T) { |
| 250 | if os.Getenv("TEST_SUBPROCESS") == "1" { |
no test coverage detected