src.elv.sh@v0.21.0-dev.0.20240515223629-06979efb9a2a/pkg/cli/modes/navigation_unix_test.go (about)

     1  //go:build unix
     2  
     3  package modes
     4  
     5  import (
     6  	"os"
     7  	"syscall"
     8  	"testing"
     9  
    10  	. "src.elv.sh/pkg/cli/clitest"
    11  	"src.elv.sh/pkg/cli/term"
    12  	"src.elv.sh/pkg/must"
    13  	"src.elv.sh/pkg/testutil"
    14  )
    15  
    16  func TestNavigation_NoPreviewForNamedPipes(t *testing.T) {
    17  	// A previous implementation tried to call os.Open on named pipes, which can
    18  	// block indefinitely. Ensure that this no longer happens.
    19  	testutil.InTempDir(t)
    20  	must.OK(os.Mkdir("d", 0777))
    21  	must.OK(syscall.Mkfifo("d/pipe", 0666))
    22  	must.OK(os.Chdir("d"))
    23  	f := setupNav(t)
    24  	defer f.Stop()
    25  
    26  	// Use the default real FS cursor.
    27  	startNavigation(f.App, NavigationSpec{})
    28  	f.TestTTY(t,
    29  		"", term.DotHere, "\n",
    30  		" NAVIGATING  \n", Styles,
    31  		"************ ",
    32  		" d    pipe          no preview for named\n", Styles,
    33  		"#### ++++++++++++++ !!!!!!!!!!!!!!!!!!!!",
    34  		"                     pipe", Styles,
    35  		"                    !!!!!",
    36  	)
    37  }