Added ANSI-art screenshots to the Travis logs

This commit is contained in:
Georges Dupéron 2018-06-28 02:27:21 +02:00
parent 7108266b96
commit 3560163759
6 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,6 @@
#!/bin/sh
screenshot="$(tempfile --suffix=".png")"
scrot "$screenshot"
"$(dirname "$0")/to_ansi.sh" "$screenshot" 131

34
ansi-screenshots/to_ansi.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
file="$1"
width="$2"
mini_png="$(tempfile --suffix=".png")"
colors_gif="$(tempfile --suffix=".gif")"
indexed_gif="$(tempfile --suffix=".gif")"
indexed_pgm="$(tempfile --suffix=".pgm")"
colors=(78,78,78 255,108,96 0,170,0 288,288,182 150,203,254 255,115,253 85,255,255 238,238,238 124,124,124 255,155,147 177,253,121 255,255,145 181,220,254 255,156,254 85,255,255 255,255,255)
args=()
for i in `seq 0 15`; do
if test $i -ge 8; then
color=$((i+8))
else
color=$((i))
fi
args+=(-fuzz 0% -fill "gray(${color})" -opaque "rgb(${colors[$i]})")
done
convert "$file" -resize "${width}x" "${mini_png}" \
&& convert +dither -remap "$(dirname "$0")/travis-palette.gif" "${mini_png}" "${colors_gif}" \
&& convert "${colors_gif}" "${args[@]}" "${indexed_gif}" \
&& convert "${indexed_gif}" "${indexed_pgm}" \
&& tail -n +4 "${indexed_pgm}" \
| hexdump -Cv \
| sed -n -r -e 's/^[0-9a-f]* (([0-9a-f]{2} ){8}) (([0-9a-f]{2} ){7}[0-9a-f]{2}).*$/\1\3/p' \
| tr '\n' ' ' \
| fold -w $((width*3)) \
| sed -r -e 's/([01])([0-7]) /[\1;3\2m██/g' \
| sed -e 's/ //g'
echo

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

View File

@ -16,4 +16,7 @@ echo "continue" > "$bochscontinue"
bochs -qf "$bochsrc" < "$bochscontinue" &
pid=$!
runsikulix -r test/check-gradient.sikuli
ansi-screenshots/ansi_screenshot.sh
kill $pid

View File

@ -6,4 +6,7 @@ os_file="example-os/os.sh"
qemu-system-i386 -drive format=raw,file=${os_file},index=0,if=floppy &
pid=$!
runsikulix -r test/check-gradient.sikuli
ansi-screenshots/ansi_screenshot.sh
kill $pid

View File

@ -17,6 +17,9 @@ VBoxManage modifyvm "$vmname" --boot1 floppy
VBoxManage startvm "$vmname" --type sdl &
pid=$!
runsikulix -r test/check-gradient.sikuli
ansi-screenshots/ansi_screenshot.sh
VBoxManage controlvm "$vmname" poweroff
wait $pid
# TODO: should ensure that the cleanup phase is always done even if the test fails.