Skip to content

Commit

Permalink
fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
photostorm committed Oct 28, 2023
1 parent 0ff5399 commit c3e5fb6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package pty
import (
"errors"
"io"
"time"
)

// ErrUnsupported is returned if a function is not
Expand All @@ -30,6 +31,8 @@ type Pty interface {

// WriteString is only used to identify Pty and Tty
WriteString(s string) (n int, err error)
SetDeadline(t time.Time) error

io.ReadWriteCloser
}

Expand All @@ -41,6 +44,7 @@ type Tty interface {
FdHolder

Name() string
SetDeadline(t time.Time) error

io.ReadWriteCloser
}
5 changes: 2 additions & 3 deletions io_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
package pty

import (
"testing"

"context"
"errors"
"os"
"runtime"
"sync"
"testing"
"time"
)

Expand Down Expand Up @@ -71,7 +70,7 @@ func TestReadClose(t *testing.T) {
}

// Open pty and setup watchdogs for graceful and not so graceful failure modes
func prepare(t *testing.T) (ptmx *os.File, done func()) {
func prepare(t *testing.T) (ptmx Pty, done func()) {
if runtime.GOOS == "darwin" {
t.Log("creack/pty uses blocking i/o on darwin intentionally:")
t.Log("> https://github.com/creack/pty/issues/52")
Expand Down
9 changes: 9 additions & 0 deletions pty_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"os"
"syscall"
"time"
"unsafe"

"golang.org/x/sys/windows"
Expand Down Expand Up @@ -137,6 +138,10 @@ func (p *WindowsPty) Close() error {
return err
}

func (t *WindowsPty) SetDeadline(value time.Time) error {
return nil
}

func (t *WindowsTty) Name() string {
return t.r.Name()
}
Expand All @@ -158,6 +163,10 @@ func (t *WindowsTty) Close() error {
return t.w.Close()
}

func (t *WindowsTty) SetDeadline(value time.Time) error {
return nil
}

func procCreatePseudoConsole(hInput windows.Handle, hOutput windows.Handle, dwFlags uint32, consoleHandle *windows.Handle) error {
var r0 uintptr
var err error
Expand Down

0 comments on commit c3e5fb6

Please sign in to comment.