-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlinoise_test.go
More file actions
54 lines (44 loc) · 952 Bytes
/
linoise_test.go
File metadata and controls
54 lines (44 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2010 The "go-linoise" Authors
//
// Use of this source code is governed by the Simplified BSD License
// that can be found in the LICENSE file.
//
// This software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
// OR CONDITIONS OF ANY KIND, either express or implied. See the License
// for more details.
package linoise
import (
"fmt"
"os"
"path"
"testing"
"syscall"
"github.com/kless/term"
)
func init() {
term.Input = os.Stderr
term.InputFD = syscall.Stderr
Init()
}
var linoiseFile = path.Join(os.TempDir(), "go_linoise")
func TestLinoise(t *testing.T) {
fmt.Println("Press ^D to exit\n")
hist, err := NewHistory(linoiseFile)
if err != nil {
t.Error(err)
}
hist.Load()
ln := NewLine(hist)
defer ln.RestoreTerm()
for {
if _, err = ln.Read(); err != nil {
if err == ErrCtrlD {
hist.Save()
} else {
fmt.Fprintf(os.Stderr, err.Error())
}
break
}
}
//os.Remove(linoiseFile)
}