mirror of
https://github.com/golang/term.git
synced 2026-01-29 07:02:06 +03:00
Also removed the obsolete appengine tag, switched _unsupported.go to negative tags, so that out-of-tree GOOSes compile out of the box, reduced use of build tags to reduce confusion, and renamed files that extend _unix.go to _unix_GOOS.go. Updates #31044 Change-Id: Ifb6f14c99713bb6a9edff630f90e9beffff3ed02 Reviewed-on: https://go-review.googlesource.com/c/term/+/258002 Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Andrea Barisani <lcars.net@gmail.com> Reviewed-by: Katie Hockman <katie@golang.org> Trust: Filippo Valsorda <filippo@golang.org>
43 lines
949 B
Go
43 lines
949 B
Go
// Copyright 2019 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package term_test
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"runtime"
|
|
"testing"
|
|
|
|
"golang.org/x/term"
|
|
)
|
|
|
|
func TestIsTerminalTempFile(t *testing.T) {
|
|
file, err := ioutil.TempFile("", "TestIsTerminalTempFile")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer os.Remove(file.Name())
|
|
defer file.Close()
|
|
|
|
if term.IsTerminal(int(file.Fd())) {
|
|
t.Fatalf("IsTerminal unexpectedly returned true for temporary file %s", file.Name())
|
|
}
|
|
}
|
|
|
|
func TestIsTerminalTerm(t *testing.T) {
|
|
if runtime.GOOS != "linux" {
|
|
t.Skipf("unknown terminal path for GOOS %v", runtime.GOOS)
|
|
}
|
|
file, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer file.Close()
|
|
|
|
if !term.IsTerminal(int(file.Fd())) {
|
|
t.Fatalf("IsTerminal unexpectedly returned false for terminal file %s", file.Name())
|
|
}
|
|
}
|