diff --git a/helpers_windows_test.go b/helpers_windows_test.go index af69ac9..851e9f2 100644 --- a/helpers_windows_test.go +++ b/helpers_windows_test.go @@ -91,7 +91,9 @@ func Test_cleanPtySequences(t *testing.T) { []byte("\u001B[1mfoo"), 0, []byte("foo"), - 0, + // Since the cleaner handles an absolute cursor position against relative output, we can't determine start + // of output and so we return a negative + -1, }, { "Cursor character (NOT position)", @@ -105,21 +107,14 @@ func Test_cleanPtySequences(t *testing.T) { []byte("\x1b[Hfoo"), 0, []byte("foo"), - 0, + -1, }, { "Home key with Window title following", []byte("\x1b[H\x1b]0;C:\\Windows\\System32\\cmd.exe\afoo"), 0, []byte("foo"), - 0, - }, - { - "Complex", - []byte("\x1b[?25l\x1b[2J\x1b[m\x1b[H\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\x1b[H\x1b]0;C:\\Users\\Nathan\\AppData\\Local\\Temp\\847774304\\bin\\state.exe\a\x1b[?25h"), - 0, - []byte(""), - 0, + -1, }, } for _, tt := range tests { diff --git a/outputproducer_test.go b/outputproducer_test.go index 5d2775e..31b4f78 100644 --- a/outputproducer_test.go +++ b/outputproducer_test.go @@ -322,7 +322,7 @@ func Test_outputProducer_cleanOutput(t *testing.T) { }{ { "Do not sanitize unfinished", - &outputProducer{}, + newOutputProducer(newTestOpts(nil, t)), 0, 0, func([]byte, int) ([]byte, int, error) { @@ -343,7 +343,7 @@ func Test_outputProducer_cleanOutput(t *testing.T) { }, { "Sanitize finished", - &outputProducer{}, + newOutputProducer(newTestOpts(nil, t)), 0, 0, func([]byte, int) ([]byte, int, error) { @@ -364,7 +364,7 @@ func Test_outputProducer_cleanOutput(t *testing.T) { }, { "Sanitize up to final line end", - &outputProducer{}, + newOutputProducer(newTestOpts(nil, t)), 0, 0, phraseSanitizer, @@ -383,7 +383,7 @@ func Test_outputProducer_cleanOutput(t *testing.T) { }, { "Sanitize from pos up to final line end", - &outputProducer{}, + newOutputProducer(newTestOpts(nil, t)), 0, 21, phraseSanitizer, @@ -402,7 +402,7 @@ func Test_outputProducer_cleanOutput(t *testing.T) { }, { "Consecutive Invocations", - &outputProducer{}, + newOutputProducer(newTestOpts(nil, t)), 0, 0, incrementalPhraseSanitizer, @@ -459,7 +459,7 @@ func Test_outputProducer_cleanOutput(t *testing.T) { }, { "Cursor Movement", - &outputProducer{}, + newOutputProducer(newTestOpts(nil, t)), 27, // Space before "me" in "sanitize me" 18, // End of first linebreak func([]byte, int) ([]byte, int, error) {