screenshotter.sh (1566B)
1 #!/bin/bash 2 3 # This script does a one-shot creation of screenshots, creating needed 4 # docker containers and removing them afterwards. During development, 5 # it might be desirable to avoid the overhead for starting and 6 # stopping the containers. Developers are encouraged to manage 7 # suitable containers themselves, calling the screenshotter.js script 8 # directly. 9 10 cleanup() { 11 [[ "${container}" ]] \ 12 && docker stop "${container}" >/dev/null \ 13 && docker rm "${container}" >/dev/null 14 container= 15 } 16 17 SS_DIR=$(dirname "$0") 18 TOP_DIR=${SS_DIR}/../.. 19 FONTS_DIR=${TOP_DIR}/test/screenshotter/unicode-fonts 20 if [[ ! -d "${FONTS_DIR}" ]]; then 21 echo "Cloning test fonts repository" 22 git clone https://github.com/Khan/KaTeX-test-fonts "${FONTS_DIR}" \ 23 || exit 2 24 fi 25 pushd "${FONTS_DIR}" || exit 2 26 git checkout --detach 99fa66a2da643218754c8236b9f9151cac71ba7c || exit 2 27 popd || exit 2 28 29 container= 30 trap cleanup EXIT 31 status=0 32 for browserTag in firefox:2.48.2 chrome:2.48.2; do 33 browser=${browserTag%:*} 34 image=selenium/standalone-${browserTag} 35 echo "Starting container for ${image}" 36 container=$(docker run -d -P ${image}) 37 [[ ${container} ]] || continue 38 echo "Container ${container:0:12} started, creating screenshots..." 39 if node "$(dirname "$0")"/screenshotter.js \ 40 --browser="${browser}" --container="${container}" "$@"; then 41 res=Done 42 else 43 res=Failed 44 status=1 45 fi 46 echo "${res} taking screenshots, stopping and removing ${container:0:12}" 47 cleanup 48 done 49 exit ${status}