(t *testing.T)
| 2855 | } |
| 2856 | |
| 2857 | func TestCopyLogWithLinePrefix_TerminalEscapeSequences(t *testing.T) { |
| 2858 | tests := []struct { |
| 2859 | name string |
| 2860 | input string |
| 2861 | }{ |
| 2862 | { |
| 2863 | name: "OSC title set sequence", |
| 2864 | input: "normal prefix\x1b]0;HIJACKED TITLE\x07trailing text\n", |
| 2865 | }, |
| 2866 | { |
| 2867 | name: "CSI color sequence", |
| 2868 | input: "\x1b[31mRED TEXT\x1b[0m normal text\n", |
| 2869 | }, |
| 2870 | { |
| 2871 | name: "screen title set sequence used in original report", |
| 2872 | input: "\x1bk;echo this is an arbitrary command;\x1b\\\n", |
| 2873 | }, |
| 2874 | { |
| 2875 | name: "CSI window title query", |
| 2876 | input: "before\x1b[21tafter\n", |
| 2877 | }, |
| 2878 | { |
| 2879 | name: "multiple escape sequences", |
| 2880 | input: "\x1b]0;title\x07\x1b[31mred\x1b[0m\x1b[21t\n", |
| 2881 | }, |
| 2882 | } |
| 2883 | |
| 2884 | for _, tt := range tests { |
| 2885 | t.Run(tt.name, func(t *testing.T) { |
| 2886 | var buf bytes.Buffer |
| 2887 | err := copyLogWithLinePrefix(&buf, strings.NewReader(tt.input), "jobname\tstep\t") |
| 2888 | require.NoError(t, err) |
| 2889 | |
| 2890 | output := buf.String() |
| 2891 | assert.NotContains(t, output, "\x1b", |
| 2892 | "output should not contain raw ESC (0x1b) bytes, got: %q", output) |
| 2893 | }) |
| 2894 | } |
| 2895 | } |
| 2896 | |
| 2897 | func TestRunLog(t *testing.T) { |
| 2898 | t.Run("when the cache dir doesn't exist, exists return false", func(t *testing.T) { |
nothing calls this directly
no test coverage detected