diff --git a/.travis.yml b/.travis.yml index fb70815c87..6302d576be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ matrix: include: - language: python env: - - TESTSUITE_BOILERPLATE=true + - TESTSUITE=boilerplate before_install: - pip install flake8 && flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics script: make test @@ -18,7 +18,7 @@ matrix: - language: go go: 1.12.9 env: - - TESTSUITE_LINT=true + - TESTSUITE=lint before_install: - sudo apt-get install -y libvirt-dev script: make test @@ -26,7 +26,7 @@ matrix: - language: go go: 1.12.9 env: - - TESTSUITE_UNIT=true + - TESTSUITE=unittest before_install: - sudo apt-get install -y libvirt-dev script: make test diff --git a/test.sh b/test.sh index 5b4d8118e7..e989e296a4 100755 --- a/test.sh +++ b/test.sh @@ -14,18 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -e -o pipefail -# TODO: fix exit code numbers -if [[ -z "$TESTSUITE_LINT" && -z "$TESTSUITE_UNIT" && -z "$TESTSUITE_BOILERPLATE" ]] -then # if all of them are not set then it is a local run - TESTSUITE_LINT=true - TESTSUITE_UNIT=true - TESTSUITE_BOILETPLATE=true -fi +set -eu -o pipefail +TESTSUITE="${TESTSUITE:-all}" exitcode=0 -if [[ ! -z "$TESTSUITE_LINT" ]] +if [ "$TESTSUITE" = "lint" ] || [ "$TESTSUITE" = "all" ] then echo "= make lint =============================================================" make -s lint-ci && echo ok || ((exitcode += 4)) @@ -35,15 +29,9 @@ then fi -if [[ ! -z "$TESTSUITE_LINT" ]] -then - echo "= make lint =============================================================" - make -s lint-ci && echo ok || ((exitcode += 4)) -fi - -if [[ ! -z "$TESTSUITE_BOILERPLATE" ]] -then +if [ "$TESTSUITE" = "boilerplate" ] || [ "$TESTSUITE" = "all" ] +then echo "= boilerplate ===========================================================" readonly PYTHON=$(type -P python || echo docker run --rm -it -v $(pwd):/minikube -w /minikube python python) readonly BDIR="./hack/boilerplate" @@ -51,17 +39,17 @@ then if [[ -n "${missing}" ]]; then echo "boilerplate missing: $missing" echo "consider running: ${BDIR}/fix.sh" - ((exitcode += 4)) + ((exitcode += 8)) else echo "ok" fi fi -if [[ ! -z "$TESTSUITE_UNIT" ]] +if [ "$TESTSUITE" = "unittest" ] || [ "$TESTSUITE" = "all" ] then echo "= schema_check ==========================================================" - go run deploy/minikube/schema_check.go >/dev/null && echo ok || ((exitcode += 8)) + go run deploy/minikube/schema_check.go >/dev/null && echo ok || ((exitcode += 16)) echo "= go test ===============================================================" cov_tmp="$(mktemp)" @@ -72,7 +60,7 @@ then -tags "container_image_ostree_stub containers_image_openpgp" \ -covermode=count \ -coverprofile="${cov_tmp}" \ - ${pkgs} && echo ok || ((exitcode += 16)) + ${pkgs} && echo ok || ((exitcode += 32)) tail -n +2 "${cov_tmp}" >>"${COVERAGE_PATH}" fi