Skip to content

Commit d128c32

Browse files
committed
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.
1 parent ea40956 commit d128c32

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

test-build.sh

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,54 @@ cd $(cd ${0%/*} && pwd -P);
2020

2121
versions=( "$@" )
2222
if [ ${#versions[@]} -eq 0 ]; then
23-
versions=( */ )
23+
versions=( */ )
2424
fi
2525
versions=( "${versions[@]%/}" )
2626

2727
for version in "${versions[@]}"; do
2828
if [[ "$version" == "docs" ]]; then
2929
continue
3030
fi
31-
31+
3232
tag=$(cat $version/Dockerfile | grep "ENV NODE_VERSION" | cut -d' ' -f3)
33-
33+
3434
info "Building $tag..."
3535
docker build -q -t node:$tag $version
36-
36+
3737
if [[ $? -gt 0 ]]; then
3838
fatal "Build of $tag failed!"
3939
else
4040
info "Build of $tag succeeded."
4141
fi
42-
42+
43+
OUTPUT=$(docker run --rm -it node:$tag node -e "process.stdout.write(process.versions.node)")
44+
if [ "$OUTPUT" != "$tag" ]; then
45+
fatal "Test of $tag failed!"
46+
else
47+
info "Test of $tag succeeded."
48+
fi
49+
4350
variants=( onbuild slim wheezy )
44-
51+
4552
for variant in "${variants[@]}"; do
4653
info "Building $tag-$variant variant..."
4754
docker build -q -t node:$tag-$variant $version/$variant
48-
55+
4956
if [[ $? -gt 0 ]]; then
5057
fatal "Build of $tag-$variant failed!"
5158
else
5259
info "Build of $tag-$variant succeeded."
5360
fi
54-
61+
62+
OUTPUT=$(docker run --rm -it node:$tag-$variant node -e "process.stdout.write(process.versions.node)")
63+
if [ "$OUTPUT" != "$tag" ]; then
64+
fatal "Test of $tag-$variant failed!"
65+
else
66+
info "Test of $tag-$variant succeeded."
67+
fi
68+
5569
done
56-
70+
5771
done
5872

5973
info "All builds successful!"

0 commit comments

Comments
 (0)