Skip to content

Commit

Permalink
refactor: streamline ShellExecutable.Start method to support dynamic …
Browse files Browse the repository at this point in the history
…read timeout
  • Loading branch information
ryan-gang committed Dec 30, 2024
1 parent 070ad50 commit 0f45ad5
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions internal/shell_executable/shell_executable.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func (b *ShellExecutable) Start(args ...string) error {

b.Setenv("PS1", utils.PROMPT)
// b.Setenv("TERM", "dumb") // test_all_success works without this too, do we need it?
readTimeout := 2000 * time.Millisecond
if len(args) > 0 && args[0] == "setLongerReadTimeout" {
readTimeout = 5000 * time.Millisecond
args = args[1:]
}

cmd := exec.Command(b.executable.Path, args...)
cmd.Env = b.env.Sorted()
Expand All @@ -77,12 +82,6 @@ func (b *ShellExecutable) Start(args ...string) error {
b.cmd = cmd
b.pty = pty
b.vt = virtual_terminal.NewStandardVT()

readTimeout := 2000 * time.Millisecond
if len(args) > 0 && args[0] == "setLongerReadTimeout" {
readTimeout = 5000 * time.Millisecond
args = args[1:]
}
b.ptyReader = condition_reader.NewConditionReader(io.TeeReader(b.pty, b.vt), readTimeout)

return nil
Expand Down

0 comments on commit 0f45ad5

Please sign in to comment.