From d128c325ce993b0b5b8256d799cdf0b02048914a Mon Sep 17 00:00:00 2001 From: Peter Petrov Date: Tue, 5 Apr 2016 04:37:43 +0300 Subject: [PATCH] Enhance test-build.sh to also perform simple execution tests In addition to testing that the images build correctly, now test-build.sh also validates that Node executes successfully, and that it is the expected version. Also fixed some inconsistent whitespace. --- test-build.sh | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/test-build.sh b/test-build.sh index 6a9f5b7e..15c38f08 100755 --- a/test-build.sh +++ b/test-build.sh @@ -20,7 +20,7 @@ cd $(cd ${0%/*} && pwd -P); versions=( "$@" ) if [ ${#versions[@]} -eq 0 ]; then - versions=( */ ) + versions=( */ ) fi versions=( "${versions[@]%/}" ) @@ -28,32 +28,46 @@ for version in "${versions[@]}"; do if [[ "$version" == "docs" ]]; then continue fi - + tag=$(cat $version/Dockerfile | grep "ENV NODE_VERSION" | cut -d' ' -f3) - + info "Building $tag..." docker build -q -t node:$tag $version - + if [[ $? -gt 0 ]]; then fatal "Build of $tag failed!" else info "Build of $tag succeeded." fi - + + OUTPUT=$(docker run --rm -it node:$tag node -e "process.stdout.write(process.versions.node)") + if [ "$OUTPUT" != "$tag" ]; then + fatal "Test of $tag failed!" + else + info "Test of $tag succeeded." + fi + variants=( onbuild slim wheezy ) - + for variant in "${variants[@]}"; do info "Building $tag-$variant variant..." docker build -q -t node:$tag-$variant $version/$variant - + if [[ $? -gt 0 ]]; then fatal "Build of $tag-$variant failed!" else info "Build of $tag-$variant succeeded." fi - + + OUTPUT=$(docker run --rm -it node:$tag-$variant node -e "process.stdout.write(process.versions.node)") + if [ "$OUTPUT" != "$tag" ]; then + fatal "Test of $tag-$variant failed!" + else + info "Test of $tag-$variant succeeded." + fi + done - + done info "All builds successful!"