8000 chore: Add (skipped) `ptytest` test that hangs on Intel Mac (and Windows) by mafredri · Pull Request #1629 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore: Add (skipped) ptytest test that hangs on Intel Mac (and Windows) #1629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test using cobra cmd
  • Loading branch information
Emyrk authored and mafredri committed Jun 7, 2022
commit 638acb6f24d3a5a3b3a237b72bac97725247e735
22 changes: 22 additions & 0 deletions pty/ptytest/ptytest_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package ptytest_test

import (
"fmt"
"os/exec"
"testing"

"github.com/spf13/cobra"
"github.com/stretchr/testify/require"

"github.com/coder/coder/pty/ptytest"
Expand All @@ -18,6 +20,7 @@ func TestPtytest(t *testing.T) {
pty.ExpectMatch("write")
pty.WriteLine("read")
})

// nolint:paralleltest
t.Run("Do not hang on Intel macOS", func(t *testing.T) {
cmd := exec.Command("sh", "-c", "echo hi, I will cause a hang")
Expand All @@ -27,4 +30,23 @@ func TestPtytest(t *testing.T) {
err := cmd.Run()
require.NoError(t, err)
})

// nolint:paralleltest
t.Run("CobraCommandWorksLinux", func(t *testing.T) {
// Example with cobra command instead of exec. More abstractions, but
// for some reason works on linux.
cmd := cobra.Command{
Use: "test",
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("Hello world")
return nil
},
}

pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
err := cmd.Execute()
require.NoError(t, err)
})
}
0