Skip to content

Commit a6922f8

Browse files
committed
Use PATH to test buffered reconnecting pty
1 parent 7c804c9 commit a6922f8

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

agent/agent_test.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,8 +1592,8 @@ const ansi = "[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)
15921592

15931593
var re = regexp.MustCompile(ansi)
15941594

1595+
//nolint:paralleltest // This test sets an environment variable.
15951596
func TestAgent_ReconnectingPTY(t *testing.T) {
1596-
t.Parallel()
15971597
if runtime.GOOS == "windows" {
15981598
// This might be our implementation, or ConPTY itself.
15991599
// It's difficult to find extensive tests for it, so
@@ -1603,17 +1603,30 @@ func TestAgent_ReconnectingPTY(t *testing.T) {
16031603

16041604
backends := []string{"Buffered", "Screen"}
16051605

1606+
_, err := exec.LookPath("screen")
1607+
hasScreen := err == nil
1608+
16061609
for _, backendType := range backends {
16071610
backendType := backendType
16081611
t.Run(backendType, func(t *testing.T) {
1609-
t.Parallel()
1610-
if runtime.GOOS == "darwin" {
1611-
t.Skip("`screen` is flaky on darwin")
1612-
} else if backendType == "Screen" {
1613-
_, err := exec.LookPath("screen")
1614-
if err != nil {
1612+
if backendType == "Screen" {
1613+
t.Parallel()
1614+
if runtime.GOOS != "linux" {
1615+
t.Skipf("`screen` is not supported on %s", runtime.GOOS)
1616+
} else if !hasScreen {
16151617
t.Skip("`screen` not found")
16161618
}
1619+
} else if hasScreen && runtime.GOOS == "linux" {
1620+
// Set up a PATH that does not have screen in it.
1621+
bashPath, err := exec.LookPath("bash")
1622+
require.NoError(t, err)
1623+
dir, err := os.MkdirTemp("/tmp", "coder-test-reconnecting-pty-PATH")
1624+
require.NoError(t, err, "create temp dir for reconnecting pty PATH")
1625+
err = os.Symlink(bashPath, filepath.Join(dir, "bash"))
1626+
require.NoError(t, err, "symlink bash into reconnecting pty PATH")
1627+
t.Setenv("PATH", dir)
1628+
} else {
1629+
t.Parallel()
16171630
}
16181631

16191632
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)

0 commit comments

Comments
 (0)