fix: use UTF-8 encoding with screen (#10190)

This will make characters like ❯ and ⇣ work, for example.
This commit is contained in:
Asher
2023-10-11 13:25:04 -08:00
committed by GitHub
parent a67a5a8105
commit a9077812e2
2 changed files with 16 additions and 4 deletions

View File

@ -1544,11 +1544,13 @@ func TestAgent_ReconnectingPTY(t *testing.T) {
_, err := exec.LookPath("screen")
hasScreen := err == nil
// Make sure UTF-8 works even with LANG set to something like C.
t.Setenv("LANG", "C")
for _, backendType := range backends {
backendType := backendType
t.Run(backendType, func(t *testing.T) {
if backendType == "Screen" {
t.Parallel()
if runtime.GOOS != "linux" {
t.Skipf("`screen` is not supported on %s", runtime.GOOS)
} else if !hasScreen {
@ -1563,8 +1565,6 @@ func TestAgent_ReconnectingPTY(t *testing.T) {
err = os.Symlink(bashPath, filepath.Join(dir, "bash"))
require.NoError(t, err, "symlink bash into reconnecting pty PATH")
t.Setenv("PATH", dir)
} else {
t.Parallel()
}
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
@ -1656,6 +1656,17 @@ func TestAgent_ReconnectingPTY(t *testing.T) {
tr4 := testutil.NewTerminalReader(t, netConn4)
require.NoError(t, tr4.ReadUntil(ctx, matchEchoOutput), "find echo output")
require.ErrorIs(t, tr4.ReadUntil(ctx, nil), io.EOF)
// Ensure that UTF-8 is supported. Avoid the terminal emulator because it
// does not appear to support UTF-8, just make sure the bytes that come
// back have the character in it.
netConn5, err := conn.ReconnectingPTY(ctx, uuid.New(), 80, 80, "echo ")
require.NoError(t, err)
defer netConn5.Close()
bytes, err := io.ReadAll(netConn5)
require.NoError(t, err)
require.Contains(t, string(bytes), "")
})
}
}