Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit312521b

Browse files
mafredriEmyrk
authored andcommitted
chore: Add (skipped)ptytest test that hangs on Intel Mac (and Windows) (#1629)
Co-authored-by: Steven Masley <stevenmasley@coder.com>
1 parent27994df commit312521b

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

‎pty/ptytest/ptytest_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
package ptytest_test
22

33
import (
4+
"fmt"
5+
"runtime"
6+
"strings"
47
"testing"
58

9+
"github.com/spf13/cobra"
10+
"github.com/stretchr/testify/require"
11+
612
"github.com/coder/coder/pty/ptytest"
713
)
814

@@ -15,4 +21,41 @@ func TestPtytest(t *testing.T) {
1521
pty.ExpectMatch("write")
1622
pty.WriteLine("read")
1723
})
24+
25+
t.Run("Cobra ptytest should not hang when output is not consumed",func(t*testing.T) {
26+
t.Parallel()
27+
28+
tests:= []struct {
29+
namestring
30+
outputstring
31+
isPlatformBugbool// See https://github.com/coder/coder/issues/2122 for more info.
32+
}{
33+
{name:"1024 is safe (does not exceed macOS buffer)",output:strings.Repeat(".",1024)},
34+
{name:"1025 exceeds macOS buffer (must not hang)",output:strings.Repeat(".",1025),isPlatformBug:true},
35+
{name:"10241 large output",output:strings.Repeat(".",10241),isPlatformBug:true},// 1024 * 10 + 1
36+
}
37+
for_,tt:=rangetests {
38+
tt:=tt
39+
// nolint:paralleltest // Avoid parallel test to more easily identify the issue.
40+
t.Run(tt.name,func(t*testing.T) {
41+
iftt.isPlatformBug&& (runtime.GOOS=="darwin"||runtime.GOOS=="windows") {
42+
t.Skip("This test hangs on macOS and Windows, see https://github.com/coder/coder/issues/2122")
43+
}
44+
45+
cmd:= cobra.Command{
46+
Use:"test",
47+
RunE:func(cmd*cobra.Command,args []string)error {
48+
fmt.Fprint(cmd.OutOrStdout(),tt.output)
49+
returnnil
50+
},
51+
}
52+
53+
pty:=ptytest.New(t)
54+
cmd.SetIn(pty.Input())
55+
cmd.SetOut(pty.Output())
56+
err:=cmd.Execute()
57+
require.NoError(t,err)
58+
})
59+
}
60+
})
1861
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp