mirror of
https://github.com/golang/term.git
synced 2026-01-29 07:02:06 +03:00
Use /dev/ptmx to create a new pseudo terminal and use this in TestIsTerminalTerm. This should fix the test failing with ENXIO on some linux builders. Change-Id: I39880d2cb538e3e9c8063ac79b5380ed00a476f5 Reviewed-on: https://go-review.googlesource.com/c/term/+/201417 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
25 lines
510 B
Go
25 lines
510 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 (
|
|
"os"
|
|
"testing"
|
|
|
|
"golang.org/x/term"
|
|
)
|
|
|
|
func TestIsTerminalTerm(t *testing.T) {
|
|
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())
|
|
}
|
|
}
|