Эх сурвалжийг харах

Improve test config, real looping of tests

Joe Ferguson 11 жил өмнө
parent
commit
a859d1ac45
2 өөрчлөгдсөн 46 нэмэгдсэн , 19 устгасан
  1. 19 13
      test/.config.sh
  2. 27 6
      test/run.sh

+ 19 - 13
test/.config.sh

@@ -1,18 +1,24 @@
 #!/bin/bash
 set -e
 
-declare -A imageIncludeTests=()
-imageIncludeTests[python]=''
-imageIncludeTests[python]+='python'
-imageIncludeTests[python]+=' other-python'
-imageIncludeTests[python-onbuild]+=''
-imageIncludeTests[python-onbuild]+='py-onbuild'
-imageIncludeTests[python:3]+=''
-imageIncludeTests[python:3]+='py-3'
+globalTests=(
+	utc
+)
 
-declare -A globalExcludeTests=()
-globalExcludeTests[utc_hello-world]=1
+declare -A testAlias=(
+	[pypy]='python'
+)
 
-declare -A globalIncludeTests=()
-globalIncludeTests[utc]=''
-globalIncludeTests[many]='debian ... ubuntu'
+declare -A imageTests=(
+	[python]='
+		python
+	'
+# example onbuild
+#	[python:onbuild]='
+#		py-onbuild
+#	'
+)
+
+declare -A globalExcludeTests=(
+	[hello-world_utc]=1
+)

+ 27 - 6
test/run.sh

@@ -44,18 +44,39 @@ done
 
 # load config lists
 # contains:
-#   imageIncludeTests
+#   globalTests
+#   testAlias
+#   imageTests
 #   globalExcludeTests
-#   globalIncludeTests
 . "$dir"/.config.sh
 
-for image in "$@"; do
-	noNamespace="${image##*/}"
+for dockerImage in "$@"; do
+	echo "testing $dockerImage"
+	
+	noNamespace="${dockerImage##*/}"
 	repo="${noNamespace%:*}"
 	tagVar="${noNamespace#*:}"
 	#version="${tagVar%-*}"
 	variant="${tagVar##*-}"
 	
-	# TODO tests
-	echo 'full:'$image 'repo:'$repo 'variant:'$variant
+	testRepo=$repo
+	[ -z "${testAlias[$repo]}" ] || testRepo="${testAlias[$repo]}"
+	
+	tests=( "${globalTests[@]}" ${imageTests[$testRepo]} ${imageTests[$testRepo:$variant]} )
+	
+	failures=0
+	currentTest=1
+	totalTest="${#tests[@]}"
+	for t in "${tests[@]}"; do
+		echo -ne "\t'$t' [$currentTest/$totalTest]..."
+		(( currentTest+=1 ))
+		
+		if [ ! -z "${globalExcludeTests[${testRepo}_$t]}" -o ! -z "${globalExcludeTests[${testRepo}:${variant}_$t]}" ]; then
+			echo 'skipping'
+			continue
+		fi
+		
+		# run test against dockerImage here
+		echo 'passed'
+	done
 done