File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 11package ptytest_test
22
33import (
4+ "fmt"
45 "os/exec"
56 "testing"
67
8+ "github.com/spf13/cobra"
79 "github.com/stretchr/testify/require"
810
911 "github.com/coder/coder/pty/ptytest"
@@ -18,6 +20,7 @@ func TestPtytest(t *testing.T) {
1820 pty .ExpectMatch ("write" )
1921 pty .WriteLine ("read" )
2022 })
23+
2124 // nolint:paralleltest
2225 t .Run ("Do not hang on Intel macOS" , func (t * testing.T ) {
2326 cmd := exec .Command ("sh" , "-c" , "echo hi, I will cause a hang" )
@@ -27,4 +30,23 @@ func TestPtytest(t *testing.T) {
2730 err := cmd .Run ()
2831 require .NoError (t , err )
2932 })
33+
34+ // nolint:paralleltest
35+ t .Run ("CobraCommandWorksLinux" , func (t * testing.T ) {
36+ // Example with cobra command instead of exec. More abstractions, but
37+ // for some reason works on linux.
38+ cmd := cobra.Command {
39+ Use : "test" ,
40+ RunE : func (cmd * cobra.Command , args []string ) error {
41+ fmt .Println ("Hello world" )
42+ return nil
43+ },
44+ }
45+
46+ pty := ptytest .New (t )
47+ cmd .SetIn (pty .Input ())
48+ cmd .SetOut (pty .Output ())
49+ err := cmd .Execute ()
50+ require .NoError (t , err )
51+ })
3052}
You can’t perform that action at this time.
0 commit comments