Browse Source

Merge pull request #759 from infosiftr/nonzero

Adjust "test/run.sh" to exit non-zero on failures
yosifkit 10 years ago
parent
commit
a691cc4c63
1 changed files with 10 additions and 2 deletions
  1. 10 2
      test/run.sh

+ 10 - 2
test/run.sh

@@ -55,11 +55,13 @@ fi
 #   globalExcludeTests
 . "$dir/config.sh"
 
+didFail=
 for dockerImage in "$@"; do
 	echo "testing $dockerImage"
 	
 	if ! docker inspect "$dockerImage" &> /dev/null; then
 		echo $'\timage does not exist!'
+		didFail=1
 		continue
 	fi
 	
@@ -92,7 +94,6 @@ for dockerImage in "$@"; do
 		tests+=( "$t" )
 	done
 	
-	failures=0
 	currentTest=0
 	totalTest="${#tests[@]}"
 	for t in "${tests[@]}"; do
@@ -110,22 +111,29 @@ for dockerImage in "$@"; do
 					if [ -f "$scriptDir/expected-std-out.txt" ] && ! d="$(echo "$output" | diff -u "$scriptDir/expected-std-out.txt" - 2>/dev/null)"; then
 						echo 'failed; unexpected output:'
 						echo "$d"
+						didFail=1
 					else
 						echo 'passed'
 					fi
 				else
 					echo 'failed'
+					didFail=1
 				fi
 			else
-				# TODO warn scipt is not executable
 				echo "skipping"
 				echo >&2 "error: $script missing, not executable or is a directory"
+				didFail=1
 				continue
 			fi
 		else
 			echo "skipping"
 			echo >&2 "error: $scriptDir is not a directory"
+			didFail=1
 			continue
 		fi
 	done
 done
+
+if [ "$didFail" ]; then
+	exit 1
+fi