@@ -1592,8 +1592,8 @@ const ansi = "[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)
1592
1592
1593
1593
var re = regexp .MustCompile (ansi )
1594
1594
1595
+ //nolint:paralleltest // This test sets an environment variable.
1595
1596
func TestAgent_ReconnectingPTY (t * testing.T ) {
1596
- t .Parallel ()
1597
1597
if runtime .GOOS == "windows" {
1598
1598
// This might be our implementation, or ConPTY itself.
1599
1599
// It's difficult to find extensive tests for it, so
@@ -1603,17 +1603,30 @@ func TestAgent_ReconnectingPTY(t *testing.T) {
1603
1603
1604
1604
backends := []string {"Buffered" , "Screen" }
1605
1605
1606
+ _ , err := exec .LookPath ("screen" )
1607
+ hasScreen := err == nil
1608
+
1606
1609
for _ , backendType := range backends {
1607
1610
backendType := backendType
1608
1611
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 {
1615
1617
t .Skip ("`screen` not found" )
1616
1618
}
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 ()
1617
1630
}
1618
1631
1619
1632
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
0 commit comments