tenox7 / ttyplot

a realtime plotting utility for terminal/console with data input from stdin
Apache License 2.0
1.13k stars 47 forks source link

Introduce automated UI testing based on asciinema #117

Closed hartwork closed 10 months ago

hartwork commented 10 months ago

This will prevent the next case of #102 right in the pull request introducing the regression.

This took quite a while to build, I ran into many interesting walls in the process and now finally have it working. Happy to answer questions about it.

hartwork commented 10 months ago

Automated visual inspection in CI? Wow! That's awesome!

@edgar-bonet glad you like the idea!

I find this really great, but at the same time I am a bit worried this could cause some friction for contributions that legitimately change the rendering. I understand in such a case one could push the change, wait for the CI to fail, download the generated artifacts, commit the actual images as the expected ones, and push again. It would be a bit cumbersome though. Could one instead just run record.sh to get the expected images?

Yes!

The fail-and-download approach would work, but I would personally see it as a fallback, as a second option, not the primary way, at least that was not intended. What I did locally to produce fresh images was basically this:

cd recordings/
./record.sh
for i in actual-*.png ; do cp ${i} ${i/actual/expected}; done
for i in expected-*.png ; do zopflipng -y ${i} ${i}; done  # https://github.com/google/zopfli
git add expected-*.png

I can make that a second script sync.sh or so if that changes something. Maybe without the git addto not interfere with the developers workflow. What do you think?

I can't find the agg command on the Ubuntu repos, is there an alternative?

agg is https://github.com/asciinema/agg and Gentoo doesn't have a package either. (It does have x11-libs/agg but that's something else). What I did and considered okay at least for myself was…

cargo install --git https://github.com/asciinema/agg
export PATH="${PATH}:${HOME}/.cargo/bin"

…and then command agg is readily available with a version fully compiled from source.