From 2ccb2d750d92f87bbfc9483095a33d04c40ca6e7 Mon Sep 17 00:00:00 2001 From: Jingfang Liu Date: Mon, 12 Mar 2018 15:45:24 -0700 Subject: [PATCH] Add testing script to invoke example testing --- cmd/kinflate/test/main.sh | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 cmd/kinflate/test/main.sh diff --git a/cmd/kinflate/test/main.sh b/cmd/kinflate/test/main.sh new file mode 100755 index 000000000..565b52c30 --- /dev/null +++ b/cmd/kinflate/test/main.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Copyright 2018 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +base_dir="$( cd "$(dirname "$0")/../../.." && pwd )" +cd "$base_dir" || { + echo "Cannot cd to '$base_dir'. Aborting." >&2 + exit 1 +} + +# Install kinflate to $GOPATH/bin and export PATH +go install ./cmd/kinflate +export PATH=$GOPATH/bin:$PATH + +home=`pwd` +example_dir="some/default/dir/for/examples" +if [ $# -eq 1 ]; then + example_dir=$1 +fi +test_targets=$(ls ${example_dir}) + +for t in ${test_targets}; do + cd ${example_dir}/${t} + if [ -x "tests/test.sh" ]; then + tests/test.sh . + fi + if [ $? -eq 0 ]; then + echo "testing ${t} passed." + else + echo "testing ${t} failed." + fi + cd ${home} +done \ No newline at end of file