mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
test: refactor CLI create tests not to use PTY (#25807)
<!-- If you have used AI to produce some or all of this PR, please ensure you have read our [AI Contribution guidelines](https://coder.com/docs/about/contributing/AI_CONTRIBUTING) before submitting. -->Part of https://github.com/coder/internal/issues/1400 Refactors CLI tests of the `create` command as the first batch of tests refactored to take a PTY out of the loop. One interesting difference I noticed between PTY and a direct pipe to standard in is that on the PTY we write `\r` to enter some input, but the kernel actually sends `\n` (or maybe `\r\n`) to the process, at least on Unix. (On windows we sent `\r\n` into the PTY). This is reflected in the implementation of the `Writer` , otherwise mostly inspired by the PTYTest equivalents.
This commit is contained in:
+3
-14
@@ -72,15 +72,10 @@ func (p *PTY) Close() error {
|
||||
if pErr != nil {
|
||||
p.Logf("PTY: Close failed: %v", pErr)
|
||||
}
|
||||
eErr := p.Expecter.Close("PTY close")
|
||||
if eErr != nil {
|
||||
p.Logf("PTY: close expecter failed: %v", eErr)
|
||||
}
|
||||
p.Expecter.Close("PTY close")
|
||||
if pErr != nil {
|
||||
p.closeErr = pErr
|
||||
return
|
||||
}
|
||||
p.closeErr = eErr
|
||||
})
|
||||
return p.closeErr
|
||||
}
|
||||
@@ -135,12 +130,6 @@ func (p *PTYCmd) Close() error {
|
||||
if pErr != nil {
|
||||
p.Logf("PTYCmd: Close failed: %v", pErr)
|
||||
}
|
||||
eErr := p.Expecter.Close("PTYCmd close")
|
||||
if eErr != nil {
|
||||
p.Logf("PTYCmd: close expecter failed: %v", eErr)
|
||||
}
|
||||
if pErr != nil {
|
||||
return pErr
|
||||
}
|
||||
return eErr
|
||||
p.Expecter.Close("PTYCmd close")
|
||||
return pErr
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user