gotestyourself / gotestsum

'go test' runner with output optimized for humans, JUnit XML for CI integration, and a summary of the test results.
Apache License 2.0
2.07k stars 122 forks source link

dots-v2 is jittery #352

Closed howardjohn closed 1 year ago

howardjohn commented 1 year ago

Using dots-v2 is very jittery/jumpy. Its harder to describe than to show:

https://asciinema.org/a/qeanwygqDJaXp6KcpWhfCOQQs

OR

cast.txt

The upload shows it a bit but not the worst part, as it gets worse as more tests are completed - but there is a size limit I was running into. To run the cast.txt do asciinema play cast.txt.

Recording was on linux alacritty. I also did gnome terminal and saw similar.

I am planning to do a bit more investigation into this, but figured i would open the issue in the meantime

howardjohn commented 1 year ago

Some of this is from tmux and/or alacritty I think as well.

Simple test to see if blinking is caused by terminal:

function clear() {
  echo -en "\e[${1}A\e[0J"
}
function write() {
  yes "$1" | head -n "$2"
}

n=40
echo -e "\n\n\n\n"
for i in {0..25}; do
  echo -en '\e[?25l'
  clear $n
  write "`seq 0 25 | xargs`" $n
  echo -en '\e[?25h'
  sleep .1
done
howardjohn commented 1 year ago

There is a semi-standard escape sequence to 'batch' a write. Example:

echo -en "\eP=1s\e\x5c"; echo foo; sleep .1; echo bar;  echo -en "\eP=2s\e\x5c"

Will write foo and bar in one go. Its not supported in tmux, though, as far as I can tell

howardjohn commented 1 year ago

Aha. I found the last piece of the puzzle. We don't need complex terminal features, we just need to stop doing clear all; write all and instead do it line-by-line. This way each cell never goes from text -> blank -> text. Pretty simple change, I will send a PR in a bit