commit 3560163759f0bc47c3e44ce15b40fcdabe93817a
parent 7108266b966d82167f39ad92588ad57f77e9046a
Author: Georges Dupéron <georges.duperon@gmail.com>
Date: Thu, 28 Jun 2018 02:27:21 +0200
Added ANSI-art screenshots to the Travis logs
Diffstat:
6 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/ansi-screenshots/ansi_screenshot.sh b/ansi-screenshots/ansi_screenshot.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+screenshot="$(tempfile --suffix=".png")"
+
+scrot "$screenshot"
+"$(dirname "$0")/to_ansi.sh" "$screenshot" 131
+\ No newline at end of file
diff --git a/ansi-screenshots/to_ansi.sh b/ansi-screenshots/to_ansi.sh
@@ -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
diff --git a/ansi-screenshots/travis-palette.gif b/ansi-screenshots/travis-palette.gif
Binary files differ.
diff --git a/test/bochs.sh b/test/bochs.sh
@@ -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
diff --git a/test/qemu-system-i386.sh b/test/qemu-system-i386.sh
@@ -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
\ No newline at end of file
diff --git a/test/virtualbox.sh b/test/virtualbox.sh
@@ -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.