Browse Source

Run the tests, woot!

Joe Ferguson 11 years ago
parent
commit
887bae017a
1 changed files with 24 additions and 4 deletions
  1. 24 4
      test/run.sh

+ 24 - 4
test/run.sh

@@ -22,15 +22,15 @@ EOUSAGE
 opts="$(getopt -o 'ht:?' --long 'dry-run,help,test:' -- "$@" || { usage >&2 && false; })"
 eval set -- "$opts"
 
-tests=()
+argTests=()
 dryRun=
 while true; do
 	flag=$1
 	shift
 	case "$flag" in
-		--dry-run)  dryRun=1 ;;
+		--dry-run) dryRun=1 ;;
 		--help|-h|'-?') usage && exit 0 ;;
-		--test|-t) tests+=( "$1" ) && shift ;;
+		--test|-t) argTests+=( "$1" ) && shift ;;
 		--) break ;;
 		*)
 			{
@@ -62,6 +62,7 @@ for dockerImage in "$@"; do
 	testRepo=$repo
 	[ -z "${testAlias[$repo]}" ] || testRepo="${testAlias[$repo]}"
 	
+	# TODO use the argTests as the definitive list of available tests
 	tests=( "${globalTests[@]}" ${imageTests[$testRepo]} ${imageTests[$testRepo:$variant]} )
 	
 	failures=0
@@ -77,6 +78,25 @@ for dockerImage in "$@"; do
 		fi
 		
 		# run test against dockerImage here
-		echo 'passed'
+		# find the scipt for the test
+		scripts=( "$(find "$dir/tests/" -maxdepth 1 -type f -name "$t"[.]*)" )
+		if [ "${#scripts[@]}" -gt 1 ]; then
+			# TODO warn that there is more than one script
+			echo -n 'too many duplicate scripts...'
+		fi
+		if [ -x "$scripts" ]; then
+			# TODO dryRun logic
+			if output="$("$scripts" $dockerImage)"; then
+				echo 'passed'
+			else
+				# TODO somethin with output (maybe also catch stderr)
+				echo 'failed'
+			fi
+		else
+			# TODO warn scipt is not executable
+			echo "skipping"
+			echo >&2 'error: not executable'
+			continue
+		fi
 	done
 done