Преглед на файлове

Merge pull request #1308 from infosiftr/test-explicit-variants

Add the notion of "explicit variants" to our test suite
yosifkit преди 10 години
родител
ревизия
503d8a710c
променени са 3 файла, в които са добавени 51 реда и са изтрити 4 реда
  1. 8 1
      test/config.sh
  2. 41 3
      test/run.sh
  3. 2 0
      test/tests/remove-onbuild.sh

+ 8 - 1
test/config.sh

@@ -8,6 +8,14 @@ globalTests+=(
 	override-cmd
 )
 
+# for "explicit" images, only run tests that are explicitly specified for that image/variant
+explicitTests+=(
+	[:onbuild]=1
+)
+imageTests[:onbuild]+='
+	override-cmd
+'
+
 testAlias+=(
 	[iojs]='node'
 	[jruby]='ruby'
@@ -157,4 +165,3 @@ globalExcludeTests+=(
 	[ruby:slim_ruby-bundler]=1
 	[ruby:slim_ruby-gems]=1
 )
-

+ 41 - 3
test/run.sh

@@ -54,6 +54,7 @@ declare -a globalTests=()
 declare -A testAlias=()
 declare -A imageTests=()
 declare -A globalExcludeTests=()
+declare -A explicitTests=()
 
 # if there are no user-specified configs, use the default config
 if [ ${#configs} -eq 0 ]; then
@@ -99,9 +100,39 @@ for dockerImage in "$@"; do
 	testRepo=$repo
 	[ -z "${testAlias[$repo]}" ] || testRepo="${testAlias[$repo]}"
 	
-	testCandidates=( "${globalTests[@]}" ${imageTests[$testRepo]} ${imageTests[$testRepo:$variant]} )
+	explicitVariant=
+	if [ \
+		"${explicitTests[:$variant]}" \
+		-o "${explicitTests[$repo:$variant]}" \
+		-o "${explicitTests[$testRepo:$variant]}" \
+	]; then
+		explicitVariant=1
+	fi
+	
+	testCandidates=()
+	if [ -z "$explicitVariant" ]; then
+		testCandidates+=( "${globalTests[@]}" )
+	fi
+	testCandidates+=(
+		${imageTests[:$variant]}
+	)
+	if [ -z "$explicitVariant" ]; then
+		testCandidates+=(
+			${imageTests[$testRepo]}
+		)
+	fi
+	testCandidates+=(
+		${imageTests[$testRepo:$variant]}
+	)
 	if [ "$testRepo" != "$repo" ]; then
-		testCandidates+=( ${imageTests[$repo]} ${imageTests[$repo:$variant]} )
+		if [ -z "$explicitVariant" ]; then
+			testCandidates+=(
+				${imageTests[$repo]}
+			)
+		fi
+		testCandidates+=(
+			${imageTests[$repo:$variant]}
+		)
 	fi
 	
 	tests=()
@@ -111,7 +142,14 @@ for dockerImage in "$@"; do
 			continue
 		fi
 		
-		if [ ! -z "${globalExcludeTests[${testRepo}_$t]}" -o ! -z "${globalExcludeTests[${testRepo}:${variant}_$t]}" -o ! -z "${globalExcludeTests[${repo}_$t]}" -o ! -z "${globalExcludeTests[${repo}:${variant}_$t]}" ]; then
+		if [ \
+			! -z "${globalExcludeTests[${testRepo}_$t]}" \
+			-o ! -z "${globalExcludeTests[${testRepo}:${variant}_$t]}" \
+			-o ! -z "${globalExcludeTests[:${variant}_$t]}" \
+			-o ! -z "${globalExcludeTests[${repo}_$t]}" \
+			-o ! -z "${globalExcludeTests[${repo}:${variant}_$t]}" \
+			-o ! -z "${globalExcludeTests[:${variant}_$t]}" \
+		]; then
 			# skipping due to exclude
 			continue
 		fi

+ 2 - 0
test/tests/remove-onbuild.sh

@@ -47,8 +47,10 @@ mkdir -p "$tmp/$newId"
 echo "$jsonString" > "$tmp/$newId/json"
 echo -n '1.0' > "$tmp/$newId/VERSION"
 dd if=/dev/zero of="$tmp/$newId/layer.tar" bs=1k count=1 &> /dev/null # empty tar file
+
 cat > "$tmp/repositories" <<EOF
 {"$outImage":{"$outTag":"$newId"}}
 EOF
+
 docker rmi -f "$out" &> /dev/null || true # avoid "already exists, renaming the old one" from "docker load"
 tar -cC "$tmp" . | docker load