| 
									
										
										
										
											2018-05-01 12:18:03 +00:00
										 |  |  | #!/usr/bin/env bash | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | set -e | 
					
						
							|  |  |  | set -u | 
					
						
							| 
									
										
										
										
											2017-05-12 19:38:52 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Author: w0rp <devw0rp@gmail.com> | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # This script runs tests for the ALE project. The following options are | 
					
						
							|  |  |  | # accepted: | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | #            -v  Enable verbose output | 
					
						
							|  |  |  | # --neovim-only  Run tests only for NeoVim | 
					
						
							|  |  |  | #    --vim-only  Run tests only for Vim | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-01 17:50:19 +00:00
										 |  |  | current_image_id=d5a1b5915b09 | 
					
						
							|  |  |  | image=w0rp/ale | 
					
						
							| 
									
										
										
										
											2017-05-12 19:38:52 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | tests='test/*.vader test/*/*.vader test/*/*/*.vader test/*/*/*.vader' | 
					
						
							| 
									
										
										
										
											2017-12-01 17:50:19 +00:00
										 |  |  | # These flags are forwarded to the script for running Vader tests. | 
					
						
							|  |  |  | verbose_flag='' | 
					
						
							|  |  |  | quiet_flag='' | 
					
						
							| 
									
										
										
										
											2017-05-12 19:38:52 +00:00
										 |  |  | run_neovim_tests=1 | 
					
						
							|  |  |  | run_vim_tests=1 | 
					
						
							|  |  |  | run_vint=1 | 
					
						
							|  |  |  | run_custom_checks=1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | while [ $# -ne 0 ]; do | 
					
						
							|  |  |  |     case $1 in | 
					
						
							|  |  |  |     -v) | 
					
						
							| 
									
										
										
										
											2017-12-01 17:50:19 +00:00
										 |  |  |         verbose_flag='-v' | 
					
						
							| 
									
										
										
										
											2017-05-12 19:38:52 +00:00
										 |  |  |         shift | 
					
						
							|  |  |  |     ;; | 
					
						
							| 
									
										
										
										
											2017-05-20 18:02:01 +00:00
										 |  |  |     -q) | 
					
						
							| 
									
										
										
										
											2017-12-01 17:50:19 +00:00
										 |  |  |         quiet_flag='-q' | 
					
						
							| 
									
										
										
										
											2017-05-20 18:02:01 +00:00
										 |  |  |         shift | 
					
						
							|  |  |  |     ;; | 
					
						
							| 
									
										
										
										
											2017-05-12 19:38:52 +00:00
										 |  |  |     --neovim-only) | 
					
						
							|  |  |  |         run_vim_tests=0 | 
					
						
							|  |  |  |         run_vint=0 | 
					
						
							|  |  |  |         run_custom_checks=0 | 
					
						
							|  |  |  |         shift | 
					
						
							|  |  |  |     ;; | 
					
						
							|  |  |  |     --vim-only) | 
					
						
							|  |  |  |         run_neovim_tests=0 | 
					
						
							|  |  |  |         run_vint=0 | 
					
						
							|  |  |  |         run_custom_checks=0 | 
					
						
							| 
									
										
										
										
											2017-07-09 13:58:17 +00:00
										 |  |  |         shift | 
					
						
							|  |  |  |     ;; | 
					
						
							|  |  |  |     --no-vint) | 
					
						
							|  |  |  |         run_vint=0 | 
					
						
							|  |  |  |         shift | 
					
						
							|  |  |  |     ;; | 
					
						
							| 
									
										
										
										
											2017-12-01 18:06:09 +00:00
										 |  |  |     --vint-only) | 
					
						
							|  |  |  |         run_vim_tests=0 | 
					
						
							|  |  |  |         run_neovim_tests=0 | 
					
						
							|  |  |  |         run_custom_checks=0 | 
					
						
							|  |  |  |         shift | 
					
						
							|  |  |  |     ;; | 
					
						
							| 
									
										
										
										
											2017-07-09 13:58:17 +00:00
										 |  |  |     --no-custom-checks) | 
					
						
							|  |  |  |         run_custom_checks=0 | 
					
						
							|  |  |  |         shift | 
					
						
							| 
									
										
										
										
											2017-05-12 19:38:52 +00:00
										 |  |  |     ;; | 
					
						
							| 
									
										
										
										
											2017-08-10 09:45:12 +00:00
										 |  |  |     --custom-checks-only) | 
					
						
							|  |  |  |         run_vim_tests=0 | 
					
						
							|  |  |  |         run_neovim_tests=0 | 
					
						
							|  |  |  |         run_vint=0 | 
					
						
							|  |  |  |         shift | 
					
						
							|  |  |  |     ;; | 
					
						
							| 
									
										
										
										
											2017-05-12 19:38:52 +00:00
										 |  |  |     --) | 
					
						
							|  |  |  |         shift | 
					
						
							|  |  |  |         break | 
					
						
							|  |  |  |     ;; | 
					
						
							|  |  |  |     -?*) | 
					
						
							|  |  |  |         echo "Invalid argument: $1" 1>&2 | 
					
						
							|  |  |  |         exit 1 | 
					
						
							|  |  |  |     ;; | 
					
						
							|  |  |  |     *) | 
					
						
							|  |  |  |         break | 
					
						
							|  |  |  |     ;; | 
					
						
							|  |  |  |     esac | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Allow tests to be passed as arguments. | 
					
						
							|  |  |  | if [ $# -ne 0 ]; then | 
					
						
							|  |  |  |     # This doesn't perfectly handle work splitting, but none of our files | 
					
						
							|  |  |  |     # have spaces in the names. | 
					
						
							|  |  |  |     tests="$*" | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-22 20:08:32 +00:00
										 |  |  | # Delete .swp files in the test directory, which cause Vim 8 to hang. | 
					
						
							|  |  |  | find test -name '*.swp' -delete | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-01 17:50:19 +00:00
										 |  |  | docker images -q w0rp/ale | grep "^$current_image_id" > /dev/null \ | 
					
						
							|  |  |  |     || docker pull "$image" | 
					
						
							| 
									
										
										
										
											2017-05-12 19:38:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-07 20:07:45 +00:00
										 |  |  | output_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | trap '{ rm -rf "$output_dir"; }' EXIT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | file_number=0 | 
					
						
							|  |  |  | pid_list='' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-01 17:50:19 +00:00
										 |  |  | for vim in $(docker run --rm "$image" ls /vim-build/bin | grep '^neovim\|^vim' ); do | 
					
						
							| 
									
										
										
										
											2017-12-07 20:07:45 +00:00
										 |  |  |     if ((run_vim_tests)) || [[ $vim =~ ^neovim ]] && ((run_neovim_tests)); then | 
					
						
							|  |  |  |         echo "Starting Vim: $vim..." | 
					
						
							|  |  |  |         file_number=$((file_number+1)) | 
					
						
							|  |  |  |         test/script/run-vader-tests $quiet_flag $verbose_flag "$vim" "$tests" \ | 
					
						
							|  |  |  |             > "$output_dir/$file_number" 2>&1 & | 
					
						
							|  |  |  |         pid_list="$pid_list $!" | 
					
						
							| 
									
										
										
										
											2017-12-01 17:50:19 +00:00
										 |  |  |     fi | 
					
						
							|  |  |  | done | 
					
						
							| 
									
										
										
										
											2017-05-12 19:38:52 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if ((run_vint)); then | 
					
						
							| 
									
										
										
										
											2017-12-07 20:07:45 +00:00
										 |  |  |     echo "Starting Vint..." | 
					
						
							|  |  |  |     file_number=$((file_number+1)) | 
					
						
							|  |  |  |     test/script/run-vint > "$output_dir/$file_number" 2>&1 & | 
					
						
							|  |  |  |     pid_list="$pid_list $!" | 
					
						
							| 
									
										
										
										
											2017-05-12 19:38:52 +00:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if ((run_custom_checks)); then | 
					
						
							| 
									
										
										
										
											2017-12-07 20:07:45 +00:00
										 |  |  |     echo "Starting Custom checks..." | 
					
						
							|  |  |  |     file_number=$((file_number+1)) | 
					
						
							|  |  |  |     test/script/custom-checks &> "$output_dir/$file_number" 2>&1 & | 
					
						
							|  |  |  |     pid_list="$pid_list $!" | 
					
						
							| 
									
										
										
										
											2017-05-12 19:38:52 +00:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-07 20:07:45 +00:00
										 |  |  | echo | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | failed=0 | 
					
						
							|  |  |  | index=0 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | for pid in $pid_list; do | 
					
						
							|  |  |  |     index=$((index+1)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ! wait "$pid"; then | 
					
						
							|  |  |  |         failed=1 | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     cat "$output_dir/$index" | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit $failed |