mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
test: Improve TestSSH/ForwardGPG stability on macOS via pty.ReadRune (#5739)
Writing to stdin for `coder ssh` too early could result in the input being discarded. To work around this we add a new `ptytest` method called `ReadRune` that lets us read one character of output. This will indicate the command is ready to accept input. It could be one character of the prompt, or of the loading message waiting for connection to be established.
This commit is contained in:
@@ -475,6 +475,10 @@ Expire-Date: 0
|
||||
// real error from being printed.
|
||||
t.Cleanup(cancel)
|
||||
|
||||
// Wait for the prompt or any output really to indicate the command has
|
||||
// started and accepting input on stdin.
|
||||
_ = pty.ReadRune(ctx)
|
||||
|
||||
pty.WriteLine("echo hello 'world'")
|
||||
pty.ExpectMatch("hello world")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user