File tree 2 files changed +0
-92
lines changed
2 files changed +0
-92
lines changed Original file line number Diff line number Diff line change @@ -17,11 +17,9 @@ package expect
17
17
import (
18
18
"bytes"
19
19
"errors"
20
- "io"
21
20
"os"
22
21
"regexp"
23
22
"strings"
24
- "syscall"
25
23
"time"
26
24
)
27
25
@@ -224,38 +222,3 @@ func String(strs ...string) Opt {
224
222
return nil
225
223
}
226
224
}
227
-
228
- // Error adds an Expect condition to exit if reading from Console's tty returns
229
- // one of the provided errors.
230
- func Error (errs ... error ) Opt {
231
- return func (opts * Opts ) error {
232
- for _ , err := range errs {
233
- opts .Matchers = append (opts .Matchers , & errorMatcher {
234
- err : err ,
235
- })
236
- }
237
- return nil
238
- }
239
- }
240
-
241
- // EOF adds an Expect condition to exit if io.EOF is returned from reading
242
- // Console's tty.
243
- func EOF (opts * Opts ) error {
244
- return Error (io .EOF )(opts )
245
- }
246
-
247
- // PTSClosed adds an Expect condition to exit if we get an
248
- // "read /dev/ptmx: input/output error" error which can occur
249
- // on Linux while reading from the ptm after the pts is closed.
250
- // Further Reading:
251
- // https://github.com/kr/pty/issues/21#issuecomment-129381749
252
- func PTSClosed (opts * Opts ) error {
253
- opts .Matchers = append (opts .Matchers , & pathErrorMatcher {
254
- pathError : os.PathError {
255
- Op : "read" ,
256
- Path : "/dev/ptmx" ,
257
- Err : syscall .Errno (0x5 ),
258
- },
259
- })
260
- return nil
261
- }
Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ package expect_test
16
16
17
17
import (
18
18
"bytes"
19
- "io"
20
19
"testing"
21
20
22
21
"github.com/stretchr/testify/require"
@@ -82,60 +81,6 @@ func TestExpectOptString(t *testing.T) {
82
81
}
83
82
}
84
83
85
- func TestExpectOptError (t * testing.T ) {
86
- t .Parallel ()
87
-
88
- tests := []struct {
89
- title string
90
- opt Opt
91
- data error
92
- expected bool
93
- }{
94
- {
95
- "No args" ,
96
- Error (),
97
- io .EOF ,
98
- false ,
99
- },
100
- {
101
- "Single arg" ,
102
- Error (io .EOF ),
103
- io .EOF ,
104
- true ,
105
- },
106
- {
107
- "Multiple arg" ,
108
- Error (io .ErrShortWrite , io .EOF ),
109
- io .EOF ,
110
- true ,
111
- },
112
- {
113
- "No matches" ,
114
- Error (io .ErrShortWrite ),
115
- io .EOF ,
116
- false ,
117
- },
118
- }
119
-
120
- for _ , test := range tests {
121
- test := test
122
- t .Run (test .title , func (t * testing.T ) {
123
- t .Parallel ()
124
-
125
- var options Opts
126
- err := test .opt (& options )
127
- require .Nil (t , err )
128
-
129
- matcher := options .Match (test .data )
130
- if test .expected {
131
- require .NotNil (t , matcher )
132
- } else {
133
- require .Nil (t , matcher )
134
- }
135
- })
136
- }
137
- }
138
-
139
84
func TestExpectOptAll (t * testing.T ) {
140
85
t .Parallel ()
141
86
You can’t perform that action at this time.
0 commit comments