Allow 'make test' to work for users who do not have jq installed
@@ -29,19 +29,25 @@ RESET='\033[0m'
LOG=$(mktemp -t tests.json.XXXXXX)
trap "rm -f $LOG" EXIT
-if [[ " ${@} " =~ "-v" ]]; then
- JQ_FILTER='select(has("Output") and (.Action=="output")) | .Output'
-else
- JQ_FILTER='select(has("Output") and (.Action=="output") and (has("Test")|not) and (.Output!="PASS\n") and (.Output!="FAIL\n") and (.Output|startswith("coverage:")|not) and (.Output|contains("[no test files]")|not)) | .Output'
-fi
-
if [[ " ${@}" =~ "pkg/skaffold" ]]; then
echo "go test ./pkg/skaffold/..."
else
echo "go test $@"
fi
-go test -json $@ | tee $LOG | jq --unbuffered -j "${JQ_FILTER}" | sed ''/FAIL/s//`printf "${RED}FAIL${RESET}"`/''
+# Keep execution simple for users who do not have jq installed
+if [[ ! $(command -v jq >/dev/null) ]]; then
+ go test $* | sed ''/FAIL/s//`printf "${RED}FAIL${RESET}"`/''
+ exit ${PIPESTATUS[0]}
+fi
+
+if [[ " ${@} " =~ "-v" ]]; then
+ JQ_FILTER='select(has("Output") and (.Action=="output")) | .Output'
+else
+ JQ_FILTER='select(has("Output") and (.Action=="output") and (has("Test")|not) and (.Output!="PASS\n") and (.Output!="FAIL\n") and (.Output|startswith("coverage:")|not) and (.Output|contains("[no test files]")|not)) | .Output'
+fi
+
+go test -json $* | tee $LOG | jq --unbuffered -j "${JQ_FILTER}" | sed ''/FAIL/s//`printf "${RED}FAIL${RESET}"`/''
RESULT=${PIPESTATUS[0]}
if [ $RESULT != 0 ]; then
