Add diff of screenshots to test suite, works good
This commit is contained in:
		
							parent
							
								
									b820ec4ef2
								
							
						
					
					
						commit
						9ca9372da1
					
				|  | @ -0,0 +1,67 @@ | ||||||
|  | #!/bin/bash | ||||||
|  | # Author:       Sick.Codes https://twitter.com/sickcodes | ||||||
|  | # Contact:      https://github.com/sickcodes, https://sick.codes | ||||||
|  | # Copyright:    sickcodes (C) 2021 | ||||||
|  | # License:      GPLv3+ | ||||||
|  | # Title:        Docker-OSX (Mac on Docker) | ||||||
|  | # Repository:   https://github.com/sickcodes/Docker-OSX | ||||||
|  | # Website:      https://sick.codes | ||||||
|  | # | ||||||
|  | # Status:       Used internally to run each image and take screenshots until they match the pngs in this folder. | ||||||
|  | #  | ||||||
|  | 
 | ||||||
|  | # note to self: # to get master images, boot each image, then screen shot using DISPLAY=:99 in the test.sh script | ||||||
|  | # scrot -o high-sierra_master.png | ||||||
|  | # scrot -o mojave_master.png | ||||||
|  | # scrot -o catalina_master.png | ||||||
|  | # scrot -o big-sur_master.png | ||||||
|  | # scrot -o monterey_master.png | ||||||
|  | # pull off remote server to the tests folder | ||||||
|  | # REMOTE_SERVER= | ||||||
|  | # scp root@"${REMOTE_SERVER}":~/*_master.png . | ||||||
|  | 
 | ||||||
|  | export DISPLAY=:99 | ||||||
|  | 
 | ||||||
|  | TESTS=( | ||||||
|  |     high-sierra | ||||||
|  |     mojave | ||||||
|  |     catalina | ||||||
|  |     big-sur | ||||||
|  |     monterey | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | # test each docker image to see if they boot to their unique respective installation screens. | ||||||
|  | 
 | ||||||
|  | for TEST in "${TESTS[@]}"; do | ||||||
|  |     # run the image detached | ||||||
|  |     docker run --rm -d \ | ||||||
|  |         --device /dev/kvm \ | ||||||
|  |         -v /tmp/.X11-unix:/tmp/.X11-unix \ | ||||||
|  |         -e "DISPLAY=:99" \ | ||||||
|  |         "sickcodes/docker-osx:${TEST}" | ||||||
|  | 
 | ||||||
|  |     # imcat the expected test screenshot to ./"${TEST}_master.txt"  | ||||||
|  |     imcat ~/Docker-OSX/tests/${TEST}_master.png > ./"${TEST}_master.txt" | ||||||
|  | 
 | ||||||
|  |     # run until the screen matches the expected screen | ||||||
|  |     while :; do | ||||||
|  |         sleep 5 | ||||||
|  |         # screenshot the Xvfb | ||||||
|  |         scrotcat > ./"${TEST}.txt" | ||||||
|  |         # diff the low res txt files created from imcat | ||||||
|  |         diff "./${TEST}.txt" ./"${TEST}_master.txt" && break | ||||||
|  |         scrotcat | ||||||
|  |     done | ||||||
|  | 
 | ||||||
|  |     # kill any containers | ||||||
|  |     docker kill "$(docker ps --format "{{.ID}}")" | ||||||
|  |      | ||||||
|  |     # ensure all containers are dead | ||||||
|  |     until [[ "$(docker ps | wc -l)" = 1 ]]; do | ||||||
|  |         sleep 1 | ||||||
|  |         docker ps | xargs docker kill | ||||||
|  |     done | ||||||
|  | 
 | ||||||
|  | done | ||||||
|  | 
 | ||||||
|  | exit 0 | ||||||
|  | @ -12,7 +12,7 @@ | ||||||
| # Repository:       https://github.com/sickcodes/Docker-OSX | # Repository:       https://github.com/sickcodes/Docker-OSX | ||||||
| # Website:          https://sick.codes | # Website:          https://sick.codes | ||||||
| # | # | ||||||
| # Status:           Work in progress. | # Status:           Used internally to auto build, run and test images on DO. | ||||||
| #  | #  | ||||||
| 
 | 
 | ||||||
| help_text="Usage: ./test.sh --branch <string> --repo <string> | help_text="Usage: ./test.sh --branch <string> --repo <string> | ||||||
|  | @ -303,6 +303,9 @@ for TEST_BUILD in "${TEST_BUILDS[@]}"; do | ||||||
|     "${TEST_BUILD}" |     "${TEST_BUILD}" | ||||||
| done | done | ||||||
| 
 | 
 | ||||||
|  | # boot each image and test | ||||||
|  | bash ./tests/boot-images.sh || exit 1 | ||||||
|  | 
 | ||||||
| if [[ "${DOCKER_USERNAME}" ]] && [[ "${DOCKER_PASSWORD}" ]]; then | if [[ "${DOCKER_USERNAME}" ]] && [[ "${DOCKER_PASSWORD}" ]]; then | ||||||
|     docker login --username "${DOCKER_USERNAME}" --password "${DOCKER_PASSWORD}" \ |     docker login --username "${DOCKER_USERNAME}" --password "${DOCKER_PASSWORD}" \ | ||||||
|         && for SHORTNAME in "${VERSION_BUILDS[@]}"; do |         && for SHORTNAME in "${VERSION_BUILDS[@]}"; do | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue