mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 22:27:35 +00:00
Add test to mintty pipe detection
This commit is contained in:
parent
80564a9bc9
commit
7cb8ea69ba
30
internal/ui/termstatus/terminal_windows_test.go
Normal file
30
internal/ui/termstatus/terminal_windows_test.go
Normal file
@ -0,0 +1,30 @@
|
||||
package termstatus
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
|
||||
rtest "github.com/restic/restic/internal/test"
|
||||
)
|
||||
|
||||
func TestIsMinTTY(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
path string
|
||||
result bool
|
||||
}{
|
||||
{`\\.\pipe\msys-dd50a72ab4668b33-pty0-to-master`, true},
|
||||
{`\\.\pipe\msys-dd50a72ab4668b33-13244-pipe-0x16`, false},
|
||||
} {
|
||||
filename, err := syscall.UTF16FromString(test.path)
|
||||
rtest.OK(t, err)
|
||||
handle, err := windows.CreateNamedPipe(&filename[0], windows.PIPE_ACCESS_DUPLEX,
|
||||
windows.PIPE_TYPE_BYTE, 1, 1024, 1024, 0, nil)
|
||||
rtest.OK(t, err)
|
||||
defer windows.CloseHandle(handle)
|
||||
|
||||
rtest.Assert(t, CanUpdateStatus(uintptr(handle)) == test.result,
|
||||
"expected CanUpdateStatus(%v) == %v", test.path, test.result)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user