-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce automated UI testing based on asciinema
- Loading branch information
Showing
8 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/actual* | ||
/diff*.png |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#! /usr/bin/env python3 | ||
# Copyright (c) 2015 by pyte authors and contributors | ||
# Copyright (c) 2023 by Sebastian Pipping <[email protected]> | ||
# | ||
# Licensed under LGPL v3, see pyte's LICENSE file for more details. | ||
# | ||
# Based on pyte's example "capture.py" | ||
# https://raw.githubusercontent.com/selectel/pyte/master/examples/capture.py | ||
|
||
import os | ||
import pty | ||
import signal | ||
import select | ||
import sys | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) < 2: | ||
sys.exit(0) | ||
|
||
p_pid, master_fd = pty.fork() | ||
if p_pid == 0: # Child. | ||
env = os.environ.copy() | ||
env['TERM'] = 'xterm-256color' | ||
os.execvpe(sys.argv[1], sys.argv[1:], env=env) | ||
assert False # never gets here | ||
|
||
# Parent. | ||
while True: | ||
try: | ||
[_master_fd], _w, _x = select.select([master_fd], [], []) | ||
except (KeyboardInterrupt, # Stop right now! | ||
ValueError): # Nothing to read. | ||
break | ||
|
||
try: | ||
data = os.read(master_fd, 1024) | ||
except OSError: | ||
break | ||
|
||
if not data: | ||
break | ||
|
||
os.kill(p_pid, signal.SIGTERM) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#! /usr/bin/env bash | ||
## | ||
## Copyright (c) 2023 by Sebastian Pipping | ||
## Apache License 2.0 | ||
## | ||
|
||
set -e -u | ||
|
||
self_dir="$(dirname "$(realpath "$(which "$0")")")" | ||
ttyplot_bin_dir="${self_dir}/.." # i.e. the local build | ||
agg_bin_dir="${HOME}/.cargo/bin" # if a local build | ||
|
||
export PATH="${ttyplot_bin_dir}:${PATH}:${agg_bin_dir}" | ||
|
||
# Consistent clock display for reproducibility | ||
export FAKETIME=yesplease | ||
|
||
|
||
cd "${self_dir}" | ||
|
||
# Check and report on runtime requirements | ||
which agg asciinema convert realpath timeout ttyplot | ||
|
||
# Enforce a diff on failure | ||
rm -f actual*.* | ||
|
||
asciinema_args=( | ||
--cols 90 | ||
--rows 20 | ||
-c 'timeout -s INT 3s sh -c "{ sleep 0.5; echo \"1 2 3 4\"; sleep 0.5; } | ttyplot -2 -c X"' | ||
-t 'ttyplot waiting, drawing, and shutting down' | ||
) | ||
|
||
./headless.py asciinema rec "${asciinema_args[@]}" actual.cast | ||
|
||
agg_args=( | ||
--fps-cap 2 | ||
--font-family 'Liberation Mono' | ||
) | ||
|
||
agg "${agg_args[@]}" actual.cast actual.gif | ||
|
||
convert -coalesce actual.gif PNG8:actual.png | ||
|
||
ls -lh actual*.* |