Browse Source

Support user-specified test config scripts

This makes it easier to use tests in this repository for images other than
official ones.
Mike Dillon 10 years ago
parent
commit
1583d08821
2 changed files with 19 additions and 11 deletions
  1. 4 4
      test/config.sh
  2. 15 7
      test/run.sh

+ 4 - 4
test/config.sh

@@ -1,14 +1,14 @@
 #!/bin/bash
 set -e
 
-globalTests=(
+globalTests+=(
 	utc
 	cve-2014--shellshock
 	no-hard-coded-passwords
 	override-cmd
 )
 
-declare -A testAlias=(
+testAlias+=(
 	[iojs]='node'
 	[jruby]='ruby'
 	[pypy]='python'
@@ -20,7 +20,7 @@ declare -A testAlias=(
 	[percona]='mysql'
 )
 
-declare -A imageTests=(
+imageTests+=(
 	[aerospike]='
 	'
 	[busybox]='
@@ -118,7 +118,7 @@ declare -A imageTests=(
 #	'
 )
 
-declare -A globalExcludeTests=(
+globalExcludeTests+=(
 	# single-binary images
 	[hello-world_utc]=1
 	[swarm_utc]=1

+ 15 - 7
test/run.sh

@@ -19,10 +19,11 @@ EOUSAGE
 }
 
 # arg handling
-opts="$(getopt -o 'ht:?' --long 'dry-run,help,test:' -- "$@" || { usage >&2 && false; })"
+opts="$(getopt -o 'ht:c:?' --long 'dry-run,help,test:,config:' -- "$@" || { usage >&2 && false; })"
 eval set -- "$opts"
 
 declare -A argTests=()
+declare -a additionalConfigs=()
 dryRun=
 while true; do
 	flag=$1
@@ -31,6 +32,7 @@ while true; do
 		--dry-run) dryRun=1 ;;
 		--help|-h|'-?') usage && exit 0 ;;
 		--test|-t) argTests["$1"]=1 && shift ;;
+		--config|-c) additionalConfigs+=("$1") && shift ;;
 		--) break ;;
 		*)
 			{
@@ -47,14 +49,20 @@ if [ $# -eq 0 ]; then
 	exit 1
 fi
 
-# load config lists
-# contains:
-#   globalTests
-#   testAlias
-#   imageTests
-#   globalExcludeTests
+# declare configuration variables
+declare -a globalTests=()
+declare -A testAlias=()
+declare -A imageTests=()
+declare -A globalExcludeTests=()
+
+# load default config
 . "$dir/config.sh"
 
+# load additional user-specified configs
+for conf in "${additionalConfigs[@]}"; do
+	. "$conf"
+done
+
 didFail=
 for dockerImage in "$@"; do
 	echo "testing $dockerImage"