Files
term/term_linux_test.go
Tobias Klauser 159e5304a9 term: use pseudo terminal in TestIsTerminalTerm on linux
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>
2019-10-16 17:06:09 +00:00

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())
}
}