This PR adds a few new functions and flags for taking/controlling screenshots.
The new flags added:
--screenshot "/path/to/file.png or /path/to/directory" - if blank, no screenshot will be attempted
--screenshot-delay > 0.0 wait for x amount of seconds before taking the screenshot
--screenshot-on-log "some string in log output" wait for this string to appear in the device log before taking a screenshot
--screenshot-on-log-timeout > 0.0 a safe-guard timeout that abort taking the screenshot if --screenshot-on-log string is not detected
I had to move around some code to enable just running vab --screenshot /tmp which is a nice simple feature to have IMO. The rest of the flags is minded towards later use with v gret to detect visual regressions in CI.
Note that it is possible to use --screenshot-on-logwithout specifying a timeout via --screenshot-on-log-timeout, in which case vab will block until the user hits Ctrl+C or the log line appears. This is, among other use-cases, helpful when debugging/developing the screenshot feature.
An example command for checking if an app builds, packages, deploys, runs and looks like you expect would then be:
vab -g --device <ID> --log-clear --screenshot /tmp/rotating_textured_quad.png --screenshot-on-log 'SOKOL_APP: ... ok' --screenshot-on-log-timeout 5 run ~/Projects/v/examples/gg/rotating_textured_quad.v
... which will build, package, deploy, start and then wait a maximum of 5 seconds for log line "SOKOL_APP: ... ok" to appear in the app's output. If the line appears, it saves the screenshot as /tmp/rotating_textured_quad.png and exits with success - if not, after 5 seconds, an error is printed along with a dump of the log it has tried to parse. Dumping the log on errors is a good way to skim for/detect any misconfiguration or unexpected output.
On top I had to insert small time.sleep() calls after certain adb commands, since this improves the deploy and launch cycle a lot.
This PR adds a few new functions and flags for taking/controlling screenshots.
The new flags added:
I had to move around some code to enable just running
vab --screenshot /tmp
which is a nice simple feature to have IMO. The rest of the flags is minded towards later use withv gret
to detect visual regressions in CI.Note that it is possible to use
--screenshot-on-log
without specifying a timeout via--screenshot-on-log-timeout
, in which casevab
will block until the user hits Ctrl+C or the log line appears. This is, among other use-cases, helpful when debugging/developing the screenshot feature.An example command for checking if an app builds, packages, deploys, runs and looks like you expect would then be:
vab -g --device <ID> --log-clear --screenshot /tmp/rotating_textured_quad.png --screenshot-on-log 'SOKOL_APP: ... ok' --screenshot-on-log-timeout 5 run ~/Projects/v/examples/gg/rotating_textured_quad.v
... which will build, package, deploy, start and then wait a maximum of 5 seconds for log line "SOKOL_APP: ... ok" to appear in the app's output. If the line appears, it saves the screenshot as/tmp/rotating_textured_quad.png
and exits with success - if not, after 5 seconds, an error is printed along with a dump of the log it has tried to parse. Dumping the log on errors is a good way to skim for/detect any misconfiguration or unexpected output.On top I had to insert small
time.sleep()
calls after certain adb commands, since this improves the deploy and launch cycle a lot.