(t *testing.T)
| 837 | } |
| 838 | |
| 839 | func newTestVirtualTerminal(t *testing.T) *expect.Console { |
| 840 | t.Helper() |
| 841 | |
| 842 | // Create a PTY and hook up a virtual terminal emulator |
| 843 | ptm, pts, err := pty.Open() |
| 844 | require.NoError(t, err) |
| 845 | |
| 846 | term := vt10x.New(vt10x.WithWriter(pts)) |
| 847 | |
| 848 | // Create a console via Expect that allows scripting against the terminal |
| 849 | consoleOpts := []expect.ConsoleOpt{ |
| 850 | expect.WithStdin(ptm), |
| 851 | expect.WithStdout(term), |
| 852 | expect.WithCloser(ptm, pts), |
| 853 | failOnExpectError(t), |
| 854 | failOnSendError(t), |
| 855 | expect.WithDefaultTimeout(time.Second), |
| 856 | // Use this logger to debug expect based tests by printing the |
| 857 | // characters being read to stdout. |
| 858 | // expect.WithLogger(log.New(os.Stdout, "", 0)), |
| 859 | } |
| 860 | |
| 861 | console, err := expect.NewConsole(consoleOpts...) |
| 862 | require.NoError(t, err) |
| 863 | t.Cleanup(func() { testCloser(t, console) }) |
| 864 | |
| 865 | return console |
| 866 | } |
| 867 | |
| 868 | func newTestVirtualTerminalIOStreams(t *testing.T, console *expect.Console) *iostreams.IOStreams { |
| 869 | t.Helper() |
no test coverage detected